Method ExecuteTransactionAsync
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.MSSqlClient.dll
ExecuteTransactionAsync<T>(SqlConnection, Func<SqlTransaction, 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 SqlConnection connection, Func<SqlTransaction, ValueTask<T>> action, IsolationLevel isolationLevel = IsolationLevel.Unspecified, CancellationToken cancellationToken = default)
Parameters
connectionSqlConnectionThe connection to transact with.
actionFunc<SqlTransaction, 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(SqlConnection, Func<SqlTransaction, 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 SqlConnection connection, Func<SqlTransaction, ValueTask> action, IsolationLevel isolationLevel = IsolationLevel.Unspecified, CancellationToken cancellationToken = default)
Parameters
connectionSqlConnectionThe connection to transact with.
actionFunc<SqlTransaction, 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>(SqlConnection, Func<SqlTransaction, 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 SqlConnection connection, Func<SqlTransaction, ValueTask<T>> action, CancellationToken cancellationToken)
Parameters
connectionSqlConnectionThe connection to transact with.
actionFunc<SqlTransaction, 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(SqlConnection, Func<SqlTransaction, 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 SqlConnection connection, Func<SqlTransaction, ValueTask> action, CancellationToken cancellationToken)
Parameters
connectionSqlConnectionThe connection to transact with.
actionFunc<SqlTransaction, 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>(SqlConnection, IsolationLevel, CancellationToken, Func<SqlTransaction, 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 SqlConnection connection, IsolationLevel isolationLevel, CancellationToken cancellationToken, Func<SqlTransaction, ValueTask<T>> action)
Parameters
connectionSqlConnectionThe 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<SqlTransaction, 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(SqlConnection, IsolationLevel, CancellationToken, Func<SqlTransaction, ValueTask>)
Begins a transaction before executing the action. Commits if there are no exceptions. Otherwise rolls-back the transaction.
public static ValueTask ExecuteTransactionAsync(this SqlConnection connection, IsolationLevel isolationLevel, CancellationToken cancellationToken, Func<SqlTransaction, ValueTask> action)
Parameters
connectionSqlConnectionThe 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<SqlTransaction, ValueTask>The handler to execute while a transaction is pending.
Returns
ExecuteTransactionAsync<T>(SqlConnection, IsolationLevel, Func<SqlTransaction, 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 SqlConnection connection, IsolationLevel isolationLevel, Func<SqlTransaction, ValueTask<T>> action, CancellationToken cancellationToken = default)
Parameters
connectionSqlConnectionThe connection to transact with.
isolationLevelIsolationLevelThe isolation level for the transaction.
actionFunc<SqlTransaction, 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(SqlConnection, IsolationLevel, Func<SqlTransaction, 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 SqlConnection connection, IsolationLevel isolationLevel, Func<SqlTransaction, ValueTask> action, CancellationToken cancellationToken = default)
Parameters
connectionSqlConnectionThe connection to transact with.
isolationLevelIsolationLevelThe isolation level for the transaction.
actionFunc<SqlTransaction, 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>(SqlConnection, CancellationToken, Func<SqlTransaction, 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 SqlConnection connection, CancellationToken cancellationToken, Func<SqlTransaction, ValueTask<T>> action)
Parameters
connectionSqlConnectionThe connection to transact with.
cancellationTokenCancellationTokenA token that if cancelled will cause this transaction to be aborted or rolled-back.
actionFunc<SqlTransaction, 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(SqlConnection, CancellationToken, Func<SqlTransaction, 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 SqlConnection connection, CancellationToken cancellationToken, Func<SqlTransaction, ValueTask> action)
Parameters
connectionSqlConnectionThe connection to transact with.
cancellationTokenCancellationTokenA token that if cancelled will cause this transaction to be aborted or rolled-back.
actionFunc<SqlTransaction, ValueTask>The handler to execute while a transaction is pending.