Class PetaPocoCommandExtensions
Provides a set of extension methods adding retry capabilities into the standard System.Data.IDbConnection implementation, which is used in PetaPoco.
Inheritance
Namespace:System.Dynamic.ExpandoObject
Assembly:Umbraco.Core.dll
Syntax
public static class PetaPocoCommandExtensions
Methods
ExecuteNonQueryWithRetry(IDbCommand)
Executes a Transact-SQL statement against the connection and returns the number of rows affected. Uses the default retry policy when executing the command.
Declaration
public static int ExecuteNonQueryWithRetry(this IDbCommand command)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDbCommand | command | The command object that is required as per extension method declaration. |
Returns
Type | Description |
---|---|
System.Int32 | The number of rows affected. |
ExecuteNonQueryWithRetry(IDbCommand, RetryPolicy)
Executes a Transact-SQL statement against the connection and returns the number of rows affected. Uses the specified retry policy when executing the command.
Declaration
public static int ExecuteNonQueryWithRetry(this IDbCommand command, RetryPolicy retryPolicy)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDbCommand | command | The command object that is required as per extension method declaration. |
RetryPolicy | retryPolicy | The retry policy defining whether to retry a command if a connection fails while executing the command. |
Returns
Type | Description |
---|---|
System.Int32 | The number of rows affected. |
ExecuteNonQueryWithRetry(IDbCommand, RetryPolicy, RetryPolicy)
Executes a Transact-SQL statement against the connection and returns the number of rows affected. Uses the specified retry policy when executing the command. Uses a separate specified retry policy when establishing a connection.
Declaration
public static int ExecuteNonQueryWithRetry(this IDbCommand command, RetryPolicy cmdRetryPolicy, RetryPolicy conRetryPolicy)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDbCommand | command | The command object that is required as per extension method declaration. |
RetryPolicy | cmdRetryPolicy | The command retry policy defining whether to retry a command if it fails while executing. |
RetryPolicy | conRetryPolicy | The connection retry policy defining whether to re-establish a connection if it drops while executing the command. |
Returns
Type | Description |
---|---|
System.Int32 | The number of rows affected. |
ExecuteReaderWithRetry(IDbCommand)
Sends the specified command to the connection and builds a SqlDataReader object containing the results. Uses the default retry policy when executing the command.
Declaration
public static IDataReader ExecuteReaderWithRetry(this IDbCommand command)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDbCommand | command | The command object that is required as per extension method declaration. |
Returns
Type | Description |
---|---|
System.Data.IDataReader | A System.Data.IDataReader object. |
ExecuteReaderWithRetry(IDbCommand, CommandBehavior)
Sends the specified command to the connection and builds a SqlDataReader object using one of the CommandBehavior values. Uses the default retry policy when executing the command.
Declaration
public static IDataReader ExecuteReaderWithRetry(this IDbCommand command, CommandBehavior behavior)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDbCommand | command | The command object that is required as per extension method declaration. |
System.Data.CommandBehavior | behavior | One of the System.Data.CommandBehavior values. |
Returns
Type | Description |
---|---|
System.Data.IDataReader | A System.Data.IDataReader object. |
ExecuteReaderWithRetry(IDbCommand, CommandBehavior, RetryPolicy)
Sends the specified command to the connection and builds a SqlDataReader object using one of the CommandBehavior values. Uses the specified retry policy when executing the command.
Declaration
public static IDataReader ExecuteReaderWithRetry(this IDbCommand command, CommandBehavior behavior, RetryPolicy retryPolicy)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDbCommand | command | The command object that is required as per extension method declaration. |
System.Data.CommandBehavior | behavior | One of the System.Data.CommandBehavior values. |
RetryPolicy | retryPolicy | The retry policy defining whether to retry a command if a connection fails while executing the command. |
Returns
Type | Description |
---|---|
System.Data.IDataReader | A System.Data.SqlClient.SqlDataReader object. |
ExecuteReaderWithRetry(IDbCommand, CommandBehavior, RetryPolicy, RetryPolicy)
Sends the specified command to the connection and builds a SqlDataReader object using one of the CommandBehavior values. Uses the specified retry policy when executing the command. Uses a separate specified retry policy when establishing a connection.
Declaration
public static IDataReader ExecuteReaderWithRetry(this IDbCommand command, CommandBehavior behavior, RetryPolicy cmdRetryPolicy, RetryPolicy conRetryPolicy)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDbCommand | command | The command object that is required as per extension method declaration. |
System.Data.CommandBehavior | behavior | One of the System.Data.CommandBehavior values. |
RetryPolicy | cmdRetryPolicy | The command retry policy defining whether to retry a command if it fails while executing. |
RetryPolicy | conRetryPolicy | The connection retry policy defining whether to re-establish a connection if it drops while executing the command. |
Returns
Type | Description |
---|---|
System.Data.IDataReader | A System.Data.IDataReader object. |
ExecuteReaderWithRetry(IDbCommand, RetryPolicy)
Sends the specified command to the connection and builds a SqlDataReader object containing the results. Uses the specified retry policy when executing the command.
Declaration
public static IDataReader ExecuteReaderWithRetry(this IDbCommand command, RetryPolicy retryPolicy)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDbCommand | command | The command object that is required as per extension method declaration. |
RetryPolicy | retryPolicy | The retry policy defining whether to retry a command if a connection fails while executing the command. |
Returns
Type | Description |
---|---|
System.Data.IDataReader | A System.Data.IDataReader object. |
ExecuteReaderWithRetry(IDbCommand, RetryPolicy, RetryPolicy)
Sends the specified command to the connection and builds a SqlDataReader object containing the results. Uses the specified retry policy when executing the command. Uses a separate specified retry policy when establishing a connection.
Declaration
public static IDataReader ExecuteReaderWithRetry(this IDbCommand command, RetryPolicy cmdRetryPolicy, RetryPolicy conRetryPolicy)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDbCommand | command | The command object that is required as per extension method declaration. |
RetryPolicy | cmdRetryPolicy | The command retry policy defining whether to retry a command if it fails while executing. |
RetryPolicy | conRetryPolicy | The connection retry policy defining whether to re-establish a connection if it drops while executing the command. |
Returns
Type | Description |
---|---|
System.Data.IDataReader | A System.Data.IDataReader object. |
ExecuteScalarWithRetry(IDbCommand)
Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored. Uses the default retry policy when executing the command.
Declaration
public static object ExecuteScalarWithRetry(this IDbCommand command)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDbCommand | command | The command object that is required as per extension method declaration. |
Returns
Type | Description |
---|---|
System.Object | The first column of the first row in the result set, or a null reference if the result set is empty. Returns a maximum of 2033 characters. |
ExecuteScalarWithRetry(IDbCommand, RetryPolicy)
Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored. Uses the specified retry policy when executing the command.
Declaration
public static object ExecuteScalarWithRetry(this IDbCommand command, RetryPolicy retryPolicy)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDbCommand | command | The command object that is required as per extension method declaration. |
RetryPolicy | retryPolicy | The retry policy defining whether to retry a command if a connection fails while executing the command. |
Returns
Type | Description |
---|---|
System.Object | The first column of the first row in the result set, or a null reference if the result set is empty. Returns a maximum of 2033 characters. |
ExecuteScalarWithRetry(IDbCommand, RetryPolicy, RetryPolicy)
Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored. Uses the specified retry policy when executing the command. Uses a separate specified retry policy when establishing a connection.
Declaration
public static object ExecuteScalarWithRetry(this IDbCommand command, RetryPolicy cmdRetryPolicy, RetryPolicy conRetryPolicy)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDbCommand | command | The command object that is required as per extension method declaration. |
RetryPolicy | cmdRetryPolicy | The command retry policy defining whether to retry a command if it fails while executing. |
RetryPolicy | conRetryPolicy | The connection retry policy defining whether to re-establish a connection if it drops while executing the command. |
Returns
Type | Description |
---|---|
System.Object | The first column of the first row in the result set, or a null reference if the result set is empty. Returns a maximum of 2033 characters. |