Delen via


SqlServerRetryingExecutionStrategy Class

Definition

An IExecutionStrategy implementation for retrying failed executions on SQL Server.

public class SqlServerRetryingExecutionStrategy : Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy
type SqlServerRetryingExecutionStrategy = class
    inherit ExecutionStrategy
Public Class SqlServerRetryingExecutionStrategy
Inherits ExecutionStrategy
Inheritance
SqlServerRetryingExecutionStrategy

Remarks

This strategy is specifically tailored to SQL Server (including Azure SQL). It is pre-configured with error numbers for transient errors that can be retried. Additional error numbers to retry on can also be supplied.

The service lifetime is Scoped. This means that each DbContext instance will use its own instance of this service. The implementation may depend on other services registered with any lifetime. The implementation does not need to be thread-safe.

See Connection resiliency and database retries for more information and examples.

Constructors

SqlServerRetryingExecutionStrategy(DbContext, Int32, TimeSpan, ICollection<Int32>)

Creates a new instance of SqlServerRetryingExecutionStrategy.

SqlServerRetryingExecutionStrategy(DbContext, Int32, TimeSpan, IEnumerable<Int32>)

Creates a new instance of SqlServerRetryingExecutionStrategy.

SqlServerRetryingExecutionStrategy(DbContext, Int32)

Creates a new instance of SqlServerRetryingExecutionStrategy.

SqlServerRetryingExecutionStrategy(DbContext)

Creates a new instance of SqlServerRetryingExecutionStrategy.

SqlServerRetryingExecutionStrategy(ExecutionStrategyContext, Int32, TimeSpan, ICollection<Int32>)

Creates a new instance of SqlServerRetryingExecutionStrategy.

SqlServerRetryingExecutionStrategy(ExecutionStrategyContext, Int32)

Creates a new instance of SqlServerRetryingExecutionStrategy.

SqlServerRetryingExecutionStrategy(ExecutionStrategyContext)

Creates a new instance of SqlServerRetryingExecutionStrategy.

SqlServerRetryingExecutionStrategy(ExecutionStrategyDependencies, IEnumerable<Int32>)

Creates a new instance of SqlServerRetryingExecutionStrategy.

SqlServerRetryingExecutionStrategy(ExecutionStrategyDependencies, Int32, TimeSpan, ICollection<Int32>)

Creates a new instance of SqlServerRetryingExecutionStrategy.

SqlServerRetryingExecutionStrategy(ExecutionStrategyDependencies, Int32, TimeSpan, IEnumerable<Int32>)

Creates a new instance of SqlServerRetryingExecutionStrategy.

SqlServerRetryingExecutionStrategy(ExecutionStrategyDependencies, Int32)

Creates a new instance of SqlServerRetryingExecutionStrategy.

SqlServerRetryingExecutionStrategy(ExecutionStrategyDependencies)

Creates a new instance of SqlServerRetryingExecutionStrategy.

Fields

DefaultMinDelayThrottling

The default minimum time delay between retries for throttling errors.

Properties

AdditionalErrorNumbers

Additional SQL error numbers that should be considered transient.

Context

The context on which the operations will be invoked.

(Inherited from ExecutionStrategy)
Dependencies

Dependencies for this service.

(Inherited from ExecutionStrategy)
ExceptionsEncountered

The list of exceptions that caused the operation to be retried so far.

(Inherited from ExecutionStrategy)
Logger

The logger for this ExecutionStrategy.

(Inherited from ExecutionStrategy)
MaxRetryCount

The maximum number of retry attempts.

(Inherited from ExecutionStrategy)
MaxRetryDelay

The maximum delay between retries.

(Inherited from ExecutionStrategy)
Random

A pseudo-random number generator that can be used to vary the delay between retries.

(Inherited from ExecutionStrategy)
RetriesOnFailure

Indicates whether this IExecutionStrategy might retry the execution after a failure.

(Inherited from ExecutionStrategy)

Methods

Execute<TState,TResult>(Func<TState,TResult>, Func<TState,ExecutionResult<TResult>>, TState)

Executes the specified operation and returns the result.

(Inherited from ExecutionStrategy)
Execute<TState,TResult>(TState, Func<DbContext,TState,TResult>, Func<DbContext,TState,ExecutionResult<TResult>>)

Executes the specified operation and returns the result.

(Inherited from ExecutionStrategy)
ExecuteAsync<TState,TResult>(Func<TState,CancellationToken,Task<TResult>>, Func<TState,CancellationToken,Task<ExecutionResult<TResult>>>, TState, CancellationToken)

Executes the specified asynchronous operation and returns the result.

(Inherited from ExecutionStrategy)
ExecuteAsync<TState,TResult>(TState, Func<DbContext,TState,CancellationToken, Task<TResult>>, Func<DbContext,TState,CancellationToken,Task<ExecutionResult<TResult>>>, CancellationToken)

Executes the specified asynchronous operation and returns the result.

(Inherited from ExecutionStrategy)
ExecuteInTransaction<TState,TResult>(Func<TState,TResult>, Func<TState,Boolean>, TState)

Executes the specified operation in a transaction and returns the result after commiting it.

(Inherited from ExecutionStrategy)
ExecuteInTransactionAsync<TState,TResult>(Func<TState,CancellationToken, Task<TResult>>, Func<TState,CancellationToken,Task<Boolean>>, TState, CancellationToken)

Executes the specified asynchronous operation and returns the result.

(Inherited from ExecutionStrategy)
GetNextDelay(Exception)

Determines whether the operation should be retried and the delay before the next attempt.

OnFirstExecution()

Method called before the first operation execution

(Inherited from ExecutionStrategy)
OnRetry()

Method called before retrying the operation execution

(Inherited from ExecutionStrategy)
ShouldRetryOn(Exception)

Determines whether the specified exception represents a transient failure that can be compensated by a retry. Additional exceptions to retry on can be passed to the constructor.

ShouldVerifySuccessOn(Exception)

Determines whether the specified exception could be thrown after a successful execution.

(Inherited from ExecutionStrategy)

Extension Methods

Execute(IExecutionStrategy, Action)

Executes the specified operation.

Execute<TState>(IExecutionStrategy, TState, Action<TState>)

Executes the specified operation.

Execute<TState>(IExecutionStrategy, Action<TState>, TState)

Executes the specified operation.

Execute<TResult>(IExecutionStrategy, Func<TResult>)

Executes the specified operation and returns the result.

Execute<TState,TResult>(IExecutionStrategy, TState, Func<TState,TResult>, Func<TState,ExecutionResult<TResult>>)

Executes the specified operation and returns the result.

Execute<TState,TResult>(IExecutionStrategy, TState, Func<TState,TResult>)

Executes the specified operation and returns the result.

Execute<TState,TResult>(IExecutionStrategy, Func<TState,TResult>, TState)

Executes the specified operation and returns the result.

Execute<TState,TResult>(IExecutionStrategy, Func<TState,TResult>, Func<TState,ExecutionResult<TResult>>, TState)
Obsolete.

Executes the specified operation and returns the result.

ExecuteAsync(IExecutionStrategy, Func<CancellationToken,Task>, CancellationToken)

Executes the specified asynchronous operation.

ExecuteAsync(IExecutionStrategy, Func<Task>)

Executes the specified asynchronous operation.

ExecuteAsync<TState>(IExecutionStrategy, TState, Func<TState,CancellationToken,Task>, CancellationToken)

Executes the specified asynchronous operation.

ExecuteAsync<TState>(IExecutionStrategy, TState, Func<TState,Task>)

Executes the specified asynchronous operation.

ExecuteAsync<TState>(IExecutionStrategy, Func<TState,CancellationToken,Task>, TState, CancellationToken)

Executes the specified asynchronous operation.

ExecuteAsync<TState>(IExecutionStrategy, Func<TState,Task>, TState)

Executes the specified asynchronous operation.

ExecuteAsync<TResult>(IExecutionStrategy, Func<CancellationToken,Task<TResult>>, CancellationToken)

Executes the specified asynchronous operation and returns the result.

ExecuteAsync<TResult>(IExecutionStrategy, Func<Task<TResult>>)

Executes the specified asynchronous operation and returns the result.

ExecuteAsync<TState,TResult>(IExecutionStrategy, TState, Func<TState, CancellationToken,Task<TResult>>, Func<TState,CancellationToken, Task<ExecutionResult<TResult>>>, CancellationToken)

Executes the specified asynchronous operation and returns the result.

ExecuteAsync<TState,TResult>(IExecutionStrategy, TState, Func<TState,CancellationToken,Task<TResult>>, CancellationToken)

Executes the specified asynchronous operation and returns the result.

ExecuteAsync<TState,TResult>(IExecutionStrategy, TState, Func<TState,Task<TResult>>)

Executes the specified asynchronous operation and returns the result.

ExecuteAsync<TState,TResult>(IExecutionStrategy, Func<TState,CancellationToken,Task<TResult>>, TState, CancellationToken)

Executes the specified asynchronous operation and returns the result.

ExecuteAsync<TState,TResult>(IExecutionStrategy, Func<TState,Task<TResult>>, TState)

Executes the specified asynchronous operation and returns the result.

ExecuteInTransaction(IExecutionStrategy, Action, Func<Boolean>)

Executes the specified operation in a transaction. Allows to check whether the transaction has been rolled back if an error occurs during commit.

ExecuteInTransaction<TState>(IExecutionStrategy, TState, Action<TState>, Func<TState,Boolean>)

Executes the specified operation in a transaction. Allows to check whether the transaction has been rolled back if an error occurs during commit.

ExecuteInTransaction<TResult>(IExecutionStrategy, Func<TResult>, Func<Boolean>)

Executes the specified operation in a transaction and returns the result. Allows to check whether the transaction has been rolled back if an error occurs during commit.

ExecuteInTransaction<TState,TResult>(IExecutionStrategy, TState, Func<TState,TResult>, Func<TState,Boolean>)

Executes the specified operation in a transaction and returns the result. Allows to check whether the transaction has been rolled back if an error occurs during commit.

ExecuteInTransaction<TState,TResult>(IExecutionStrategy, Func<TState,TResult>, Func<TState,Boolean>, TState, DbContext)

Executes the specified operation in a transaction and returns the result after commiting it.

ExecuteInTransactionAsync(IExecutionStrategy, Func<CancellationToken,Task>, Func<CancellationToken,Task<Boolean>>, CancellationToken)

Executes the specified asynchronous operation in a transaction. Allows to check whether the transaction has been rolled back if an error occurs during commit.

ExecuteInTransactionAsync(IExecutionStrategy, Func<Task>, Func<Task<Boolean>>)

Executes the specified asynchronous operation in a transaction. Allows to check whether the transaction has been rolled back if an error occurs during commit.

ExecuteInTransactionAsync<TState>(IExecutionStrategy, TState, Func<TState,CancellationToken,Task>, Func<TState,CancellationToken, Task<Boolean>>, CancellationToken)

Executes the specified asynchronous operation in a transaction. Allows to check whether the transaction has been rolled back if an error occurs during commit.

ExecuteInTransactionAsync<TResult>(IExecutionStrategy, Func<CancellationToken, Task<TResult>>, Func<CancellationToken,Task<Boolean>>, CancellationToken)

Executes the specified asynchronous operation in a transaction and returns the result. Allows to check whether the transaction has been rolled back if an error occurs during commit.

ExecuteInTransactionAsync<TState,TResult>(IExecutionStrategy, TState, Func<TState,CancellationToken,Task<TResult>>, Func<TState, CancellationToken,Task<Boolean>>, CancellationToken)

Executes the specified asynchronous operation in a transaction and returns the result. Allows to check whether the transaction has been rolled back if an error occurs during commit.

ExecuteInTransactionAsync<TState,TResult>(IExecutionStrategy, Func<TState,CancellationToken,Task<TResult>>, Func<TState,CancellationToken, Task<Boolean>>, TState, DbContext, CancellationToken)

Executes the specified asynchronous operation and returns the result.

ExecuteInTransaction(IExecutionStrategy, Action, Func<Boolean>, IsolationLevel)

Executes the specified operation in a transaction. Allows to check whether the transaction has been rolled back if an error occurs during commit.

ExecuteInTransaction<TState>(IExecutionStrategy, TState, Action<TState>, Func<TState,Boolean>, IsolationLevel)

Executes the specified operation in a transaction. Allows to check whether the transaction has been rolled back if an error occurs during commit.

ExecuteInTransaction<TResult>(IExecutionStrategy, Func<TResult>, Func<Boolean>, IsolationLevel)

Executes the specified operation in a transaction and returns the result. Allows to check whether the transaction has been rolled back if an error occurs during commit.

ExecuteInTransaction<TState,TResult>(IExecutionStrategy, TState, Func<TState,TResult>, Func<TState,Boolean>, IsolationLevel)

Executes the specified operation in a transaction and returns the result. Allows to check whether the transaction has been rolled back if an error occurs during commit.

ExecuteInTransactionAsync(IExecutionStrategy, Func<CancellationToken,Task>, Func<CancellationToken,Task<Boolean>>, IsolationLevel, CancellationToken)

Executes the specified asynchronous operation in a transaction. Allows to check whether the transaction has been rolled back if an error occurs during commit.

ExecuteInTransactionAsync(IExecutionStrategy, Func<Task>, Func<Task<Boolean>>, IsolationLevel)

Executes the specified asynchronous operation in a transaction. Allows to check whether the transaction has been rolled back if an error occurs during commit.

ExecuteInTransactionAsync<TState>(IExecutionStrategy, TState, Func<TState,CancellationToken,Task>, Func<TState,CancellationToken, Task<Boolean>>, IsolationLevel, CancellationToken)

Executes the specified asynchronous operation in a transaction. Allows to check whether the transaction has been rolled back if an error occurs during commit.

ExecuteInTransactionAsync<TResult>(IExecutionStrategy, Func<CancellationToken, Task<TResult>>, Func<CancellationToken,Task<Boolean>>, IsolationLevel, CancellationToken)

Executes the specified asynchronous operation in a transaction and returns the result. Allows to check whether the transaction has been rolled back if an error occurs during commit.

ExecuteInTransactionAsync<TState,TResult>(IExecutionStrategy, TState, Func<TState,CancellationToken,Task<TResult>>, Func<TState, CancellationToken,Task<Boolean>>, IsolationLevel, CancellationToken)

Executes the specified asynchronous operation and returns the result. Allows to check whether the transaction has been rolled back if an error occurs during commit.

Applies to