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