Method ExecuteTransactionAsync
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
ExecuteTransactionAsync<T>(DbConnection, Func<DbTransaction, ValueTask<T>>, IsolationLevel, CancellationToken)
Begins a transaction before executing the action. Commits if there are no exceptions and the optional provided token is not cancelled. Otherwise rolls-back the transaction.
public static ValueTask<T> ExecuteTransactionAsync<T>(this DbConnection connection, Func<DbTransaction, ValueTask<T>> action, IsolationLevel isolationLevel = IsolationLevel.Unspecified, CancellationToken cancellationToken = default)
Parameters
connectionDbConnectionThe connection to transact with.
actionFunc<DbTransaction, ValueTask<T>>The handler to execute while a transaction is pending.
isolationLevelIsolationLevelThe isolation level for the transaction.
cancellationTokenCancellationTokenA token that if cancelled will cause this transaction to be aborted or rolled-back.
Returns
- ValueTask<T>
The value of the awaited action.
Type Parameters
TThe value returned from the action.
ExecuteTransactionAsync(DbConnection, Func<DbTransaction, ValueTask>, IsolationLevel, CancellationToken)
Begins a transaction before executing the action. Commits if there are no exceptions and the optional provided token is not cancelled. Otherwise rolls-back the transaction.
public static ValueTask ExecuteTransactionAsync(this DbConnection connection, Func<DbTransaction, ValueTask> action, IsolationLevel isolationLevel = IsolationLevel.Unspecified, CancellationToken cancellationToken = default)
Parameters
connectionDbConnectionThe connection to transact with.
actionFunc<DbTransaction, ValueTask>The handler to execute while a transaction is pending.
isolationLevelIsolationLevelThe isolation level for the transaction.
cancellationTokenCancellationTokenA token that if cancelled will cause this transaction to be aborted or rolled-back.
Returns
ExecuteTransactionAsync<T>(DbConnection, Func<DbTransaction, ValueTask<T>>, CancellationToken)
Begins a transaction before executing the action. Commits if there are no exceptions and the optional provided token is not cancelled. Otherwise rolls-back the transaction.
public static ValueTask<T> ExecuteTransactionAsync<T>(this DbConnection connection, Func<DbTransaction, ValueTask<T>> action, CancellationToken cancellationToken)
Parameters
connectionDbConnectionThe connection to transact with.
actionFunc<DbTransaction, ValueTask<T>>The handler to execute while a transaction is pending.
cancellationTokenCancellationTokenA token that if cancelled will cause this transaction to be aborted or rolled-back.
Returns
- ValueTask<T>
The value of the awaited action.
Type Parameters
TThe value returned from the action.
ExecuteTransactionAsync(DbConnection, Func<DbTransaction, ValueTask>, CancellationToken)
Begins a transaction before executing the action. Commits if there are no exceptions and the optional provided token is not cancelled. Otherwise rolls-back the transaction.
public static ValueTask ExecuteTransactionAsync(this DbConnection connection, Func<DbTransaction, ValueTask> action, CancellationToken cancellationToken)
Parameters
connectionDbConnectionThe connection to transact with.
actionFunc<DbTransaction, ValueTask>The handler to execute while a transaction is pending.
cancellationTokenCancellationTokenA token that if cancelled will cause this transaction to be aborted or rolled-back.
Returns
ExecuteTransactionAsync<T>(DbConnection, IsolationLevel, CancellationToken, Func<DbTransaction, ValueTask<T>>)
Begins a transaction before executing the action. Commits if there are no exceptions. Otherwise rolls-back the transaction.
public static ValueTask<T> ExecuteTransactionAsync<T>(this DbConnection connection, IsolationLevel isolationLevel, CancellationToken cancellationToken, Func<DbTransaction, ValueTask<T>> action)
Parameters
connectionDbConnectionThe connection to transact with.
isolationLevelIsolationLevelThe isolation level for the transaction.
cancellationTokenCancellationTokenA token that if cancelled will cause this transaction to be aborted or rolled-back.
actionFunc<DbTransaction, ValueTask<T>>The handler to execute while a transaction is pending.
Returns
- ValueTask<T>
The value of the awaited action.
Type Parameters
TThe value returned from the action.
ExecuteTransactionAsync(DbConnection, IsolationLevel, CancellationToken, Func<DbTransaction, ValueTask>)
Begins a transaction before executing the action. Commits if there are no exceptions. Otherwise rolls-back the transaction.
public static ValueTask ExecuteTransactionAsync(this DbConnection connection, IsolationLevel isolationLevel, CancellationToken cancellationToken, Func<DbTransaction, ValueTask> action)
Parameters
connectionDbConnectionThe connection to transact with.
isolationLevelIsolationLevelThe isolation level for the transaction.
cancellationTokenCancellationTokenA token that if cancelled will cause this transaction to be aborted or rolled-back.
actionFunc<DbTransaction, ValueTask>The handler to execute while a transaction is pending.
Returns
ExecuteTransactionAsync<T>(DbConnection, IsolationLevel, Func<DbTransaction, ValueTask<T>>, CancellationToken)
Begins a transaction before executing the action. Commits if there are no exceptions. Otherwise rolls-back the transaction.
public static ValueTask<T> ExecuteTransactionAsync<T>(this DbConnection connection, IsolationLevel isolationLevel, Func<DbTransaction, ValueTask<T>> action, CancellationToken cancellationToken = default)
Parameters
connectionDbConnectionThe connection to transact with.
isolationLevelIsolationLevelThe isolation level for the transaction.
actionFunc<DbTransaction, ValueTask<T>>The handler to execute while a transaction is pending.
cancellationTokenCancellationTokenAn optional token that if cancelled will cause this transaction to be aborted or rolled-back.
Returns
- ValueTask<T>
The value of the awaited action.
Type Parameters
TThe value returned from the action.
ExecuteTransactionAsync(DbConnection, IsolationLevel, Func<DbTransaction, ValueTask>, CancellationToken)
Begins a transaction before executing the action. Commits if there are no exceptions. Otherwise rolls-back the transaction.
public static ValueTask ExecuteTransactionAsync(this DbConnection connection, IsolationLevel isolationLevel, Func<DbTransaction, ValueTask> action, CancellationToken cancellationToken = default)
Parameters
connectionDbConnectionThe connection to transact with.
isolationLevelIsolationLevelThe isolation level for the transaction.
actionFunc<DbTransaction, ValueTask>The handler to execute while a transaction is pending.
cancellationTokenCancellationTokenAn optional token that if cancelled will cause this transaction to be aborted or rolled-back.
Returns
ExecuteTransactionAsync<T>(DbConnection, CancellationToken, Func<DbTransaction, ValueTask<T>>)
Begins a transaction before executing the action. Commits if there are no exceptions and the optional provided token is not cancelled. Otherwise rolls-back the transaction.
public static ValueTask<T> ExecuteTransactionAsync<T>(this DbConnection connection, CancellationToken cancellationToken, Func<DbTransaction, ValueTask<T>> action)
Parameters
connectionDbConnectionThe connection to transact with.
cancellationTokenCancellationTokenA token that if cancelled will cause this transaction to be aborted or rolled-back.
actionFunc<DbTransaction, ValueTask<T>>The handler to execute while a transaction is pending.
Returns
- ValueTask<T>
The value of the awaited action.
Type Parameters
TThe value returned from the action.
ExecuteTransactionAsync(DbConnection, CancellationToken, Func<DbTransaction, ValueTask>)
Begins a transaction before executing the action. Commits if there are no exceptions and the optional provided token is not cancelled. Otherwise rolls-back the transaction.
public static ValueTask ExecuteTransactionAsync(this DbConnection connection, CancellationToken cancellationToken, Func<DbTransaction, ValueTask> action)
Parameters
connectionDbConnectionThe connection to transact with.
cancellationTokenCancellationTokenA token that if cancelled will cause this transaction to be aborted or rolled-back.
actionFunc<DbTransaction, ValueTask>The handler to execute while a transaction is pending.