RelationalExecutionStrategyExtensions.ExecuteInTransactionAsync Method
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.
Overloads
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(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<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. |
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(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.
public static System.Threading.Tasks.Task ExecuteInTransactionAsync (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, Func<System.Threading.Tasks.Task> operation, Func<System.Threading.Tasks.Task<bool>> verifySucceeded, System.Data.IsolationLevel isolationLevel);
static member ExecuteInTransactionAsync : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy * Func<System.Threading.Tasks.Task> * Func<System.Threading.Tasks.Task<bool>> * System.Data.IsolationLevel -> System.Threading.Tasks.Task
<Extension()>
Public Function ExecuteInTransactionAsync (strategy As IExecutionStrategy, operation As Func(Of Task), verifySucceeded As Func(Of Task(Of Boolean)), isolationLevel As IsolationLevel) As Task
Parameters
- strategy
- IExecutionStrategy
The strategy that will be used for the execution.
A delegate that tests whether the operation succeeded even though an exception was thrown when the transaction was being committed.
- isolationLevel
- IsolationLevel
The isolation level to use for the transaction.
Returns
A task that will run to completion if the original task completes successfully (either the first time or after retrying transient failures). If the task fails with a non-transient error or the retry limit is reached, the returned task will become faulted and the exception must be observed.
Exceptions
The operation has not succeeded after the configured number of retries.
Remarks
See Connection resiliency and database retries for more information and examples.
Applies to
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.
public static System.Threading.Tasks.Task ExecuteInTransactionAsync (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, Func<System.Threading.CancellationToken,System.Threading.Tasks.Task> operation, Func<System.Threading.CancellationToken,System.Threading.Tasks.Task<bool>> verifySucceeded, System.Data.IsolationLevel isolationLevel, System.Threading.CancellationToken cancellationToken = default);
static member ExecuteInTransactionAsync : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy * Func<System.Threading.CancellationToken, System.Threading.Tasks.Task> * Func<System.Threading.CancellationToken, System.Threading.Tasks.Task<bool>> * System.Data.IsolationLevel * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function ExecuteInTransactionAsync (strategy As IExecutionStrategy, operation As Func(Of CancellationToken, Task), verifySucceeded As Func(Of CancellationToken, Task(Of Boolean)), isolationLevel As IsolationLevel, Optional cancellationToken As CancellationToken = Nothing) As Task
Parameters
- strategy
- IExecutionStrategy
The strategy that will be used for the execution.
- operation
- Func<CancellationToken,Task>
A function that returns a started task.
- verifySucceeded
- Func<CancellationToken,Task<Boolean>>
A delegate that tests whether the operation succeeded even though an exception was thrown when the transaction was being committed.
- isolationLevel
- IsolationLevel
The isolation level to use for the transaction.
- cancellationToken
- CancellationToken
A cancellation token used to cancel the retry operation, but not operations that are already in flight or that already completed successfully.
Returns
A task that will run to completion if the original task completes successfully (either the first time or after retrying transient failures). If the task fails with a non-transient error or the retry limit is reached, the returned task will become faulted and the exception must be observed.
Exceptions
The operation has not succeeded after the configured number of retries.
If the CancellationToken is canceled.
Remarks
See Connection resiliency and database retries for more information and examples.
Applies to
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.
public static System.Threading.Tasks.Task<TResult> ExecuteInTransactionAsync<TResult> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, Func<System.Threading.CancellationToken,System.Threading.Tasks.Task<TResult>> operation, Func<System.Threading.CancellationToken,System.Threading.Tasks.Task<bool>> verifySucceeded, System.Data.IsolationLevel isolationLevel, System.Threading.CancellationToken cancellationToken = default);
static member ExecuteInTransactionAsync : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy * Func<System.Threading.CancellationToken, System.Threading.Tasks.Task<'Result>> * Func<System.Threading.CancellationToken, System.Threading.Tasks.Task<bool>> * System.Data.IsolationLevel * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Result>
<Extension()>
Public Function ExecuteInTransactionAsync(Of TResult) (strategy As IExecutionStrategy, operation As Func(Of CancellationToken, Task(Of TResult)), verifySucceeded As Func(Of CancellationToken, Task(Of Boolean)), isolationLevel As IsolationLevel, Optional cancellationToken As CancellationToken = Nothing) As Task(Of TResult)
Type Parameters
- TResult
The result type of the Task<TResult> returned by operation
.
Parameters
- strategy
- IExecutionStrategy
The strategy that will be used for the execution.
- operation
- Func<CancellationToken,Task<TResult>>
A function that returns a started task of type TResult
.
- verifySucceeded
- Func<CancellationToken,Task<Boolean>>
A delegate that tests whether the operation succeeded even though an exception was thrown when the transaction was being committed.
- isolationLevel
- IsolationLevel
The isolation level to use for the transaction.
- cancellationToken
- CancellationToken
A cancellation token used to cancel the retry operation, but not operations that are already in flight or that already completed successfully.
Returns
A task that will run to completion if the original task completes successfully (either the first time or after retrying transient failures). If the task fails with a non-transient error or the retry limit is reached, the returned task will become faulted and the exception must be observed.
Exceptions
The operation has not succeeded after the configured number of retries.
If the CancellationToken is canceled.
Remarks
See Connection resiliency and database retries for more information and examples.
Applies to
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.
public static System.Threading.Tasks.Task<TResult> ExecuteInTransactionAsync<TState,TResult> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, TState state, Func<TState,System.Threading.CancellationToken,System.Threading.Tasks.Task<TResult>> operation, Func<TState,System.Threading.CancellationToken,System.Threading.Tasks.Task<bool>> verifySucceeded, System.Data.IsolationLevel isolationLevel, System.Threading.CancellationToken cancellationToken = default);
static member ExecuteInTransactionAsync : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy * 'State * Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.Task<'Result>> * Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.Task<bool>> * System.Data.IsolationLevel * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Result>
<Extension()>
Public Function ExecuteInTransactionAsync(Of TState, TResult) (strategy As IExecutionStrategy, state As TState, operation As Func(Of TState, CancellationToken, Task(Of TResult)), verifySucceeded As Func(Of TState, CancellationToken, Task(Of Boolean)), isolationLevel As IsolationLevel, Optional cancellationToken As CancellationToken = Nothing) As Task(Of TResult)
Type Parameters
- TState
The type of the state.
- TResult
The result type of the Task<TResult> returned by operation
.
Parameters
- strategy
- IExecutionStrategy
The strategy that will be used for the execution.
- state
- TState
The state that will be passed to the operation.
- operation
- Func<TState,CancellationToken,Task<TResult>>
A function that returns a started task of type TResult
.
- verifySucceeded
- Func<TState,CancellationToken,Task<Boolean>>
A delegate that tests whether the operation succeeded even though an exception was thrown when the transaction was being committed.
- isolationLevel
- IsolationLevel
The isolation level to use for the transaction.
- cancellationToken
- CancellationToken
A cancellation token used to cancel the retry operation, but not operations that are already in flight or that already completed successfully.
Returns
A task that will run to completion if the original task completes successfully (either the first time or after retrying transient failures). If the task fails with a non-transient error or the retry limit is reached, the returned task will become faulted and the exception must be observed.
Exceptions
The operation has not succeeded after the configured number of retries.
If the CancellationToken is canceled.
Remarks
See Connection resiliency and database retries for more information and examples.
Applies to
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.
public static System.Threading.Tasks.Task ExecuteInTransactionAsync<TState> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, TState state, Func<TState,System.Threading.CancellationToken,System.Threading.Tasks.Task> operation, Func<TState,System.Threading.CancellationToken,System.Threading.Tasks.Task<bool>> verifySucceeded, System.Data.IsolationLevel isolationLevel, System.Threading.CancellationToken cancellationToken = default);
static member ExecuteInTransactionAsync : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy * 'State * Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.Task> * Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.Task<bool>> * System.Data.IsolationLevel * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function ExecuteInTransactionAsync(Of TState) (strategy As IExecutionStrategy, state As TState, operation As Func(Of TState, CancellationToken, Task), verifySucceeded As Func(Of TState, CancellationToken, Task(Of Boolean)), isolationLevel As IsolationLevel, Optional cancellationToken As CancellationToken = Nothing) As Task
Type Parameters
- TState
The type of the state.
Parameters
- strategy
- IExecutionStrategy
The strategy that will be used for the execution.
- state
- TState
The state that will be passed to the operation.
- operation
- Func<TState,CancellationToken,Task>
A function that returns a started task.
- verifySucceeded
- Func<TState,CancellationToken,Task<Boolean>>
A delegate that tests whether the operation succeeded even though an exception was thrown when the transaction was being committed.
- isolationLevel
- IsolationLevel
The isolation level to use for the transaction.
- cancellationToken
- CancellationToken
A cancellation token used to cancel the retry operation, but not operations that are already in flight or that already completed successfully.
Returns
A task that will run to completion if the original task completes successfully (either the first time or after retrying transient failures). If the task fails with a non-transient error or the retry limit is reached, the returned task will become faulted and the exception must be observed.
Exceptions
The operation has not succeeded after the configured number of retries.
If the CancellationToken is canceled.
Remarks
See Connection resiliency and database retries for more information and examples.
Applies to
Entity Framework