ExecutionStrategy Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
The base class for IExecutionStrategy implementations.
public abstract class ExecutionStrategy : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy
type ExecutionStrategy = class
interface IExecutionStrategy
Public MustInherit Class ExecutionStrategy
Implements IExecutionStrategy
- Inheritance
-
ExecutionStrategy
- Derived
- Implements
Remarks
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
ExecutionStrategy(DbContext, Int32, TimeSpan) |
Creates a new instance of ExecutionStrategy. |
ExecutionStrategy(ExecutionStrategyContext, Int32, TimeSpan) |
Creates a new instance of ExecutionStrategy. |
ExecutionStrategy(ExecutionStrategyDependencies, Int32, TimeSpan) |
Creates a new instance of ExecutionStrategy. |
Fields
DefaultMaxDelay |
The default maximum time delay between retries, must be nonnegative. |
DefaultMaxRetryCount |
The default number of retry attempts. |
Properties
Context |
The context on which the operations will be invoked. |
Current |
Gets or sets the currently executing strategy. All nested calls will be handled by the outermost strategy. |
Dependencies |
Dependencies for this service. |
ExceptionsEncountered |
The list of exceptions that caused the operation to be retried so far. |
Logger |
The logger for this ExecutionStrategy. |
MaxRetryCount |
The maximum number of retry attempts. |
MaxRetryDelay |
The maximum delay between retries. |
Random |
A pseudo-random number generator that can be used to vary the delay between retries. |
RetriesOnFailure |
Indicates whether this IExecutionStrategy might retry the execution after a failure. |
Suspended |
Obsolete.
Indicates whether the strategy is suspended. The strategy is typically suspending while executing to avoid recursive execution from nested operations. |
Methods
CallOnWrappedException<TResult>(Exception, Func<Exception,TResult>) |
Recursively gets InnerException from |
Execute<TState,TResult>(Func<TState,TResult>, Func<TState,ExecutionResult<TResult>>, TState) |
Executes the specified operation and returns the result. |
Execute<TState,TResult>(TState, Func<DbContext,TState,TResult>, Func<DbContext,TState,ExecutionResult<TResult>>) |
Executes the specified operation and returns the result. |
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. |
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. |
ExecuteInTransaction<TState,TResult>(Func<TState,TResult>, Func<TState,Boolean>, TState) |
Executes the specified operation in a transaction and returns the result after commiting it. |
ExecuteInTransactionAsync<TState,TResult>(Func<TState,CancellationToken, Task<TResult>>, Func<TState,CancellationToken,Task<Boolean>>, TState, CancellationToken) |
Executes the specified asynchronous operation and returns the result. |
GetNextDelay(Exception) |
Determines whether the operation should be retried and the delay before the next attempt. |
OnFirstExecution() |
Method called before the first operation execution |
OnRetry() |
Method called before retrying the operation execution |
ShouldRetryOn(Exception) |
Determines whether the specified exception represents a transient failure that can be compensated by a retry. |
ShouldVerifySuccessOn(Exception) |
Determines whether the specified exception could be thrown after a successful execution. |
Extension Methods
Applies to
Entity Framework