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