Table of Contents

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

connection SqlConnection

The connection to transact with.

action Func<SqlTransaction, T>

The handler to execute while a transaction is pending.

isolationLevel IsolationLevel

The isolation level for the transaction.

cancellationToken CancellationToken

A token that if cancelled will cause this transaction to be aborted or rolled-back.

Returns

T

The value of the action.

Type Parameters

T

The 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

connection SqlConnection

The connection to transact with.

action Action<SqlTransaction>

The handler to execute while a transaction is pending.

isolationLevel IsolationLevel

The isolation level for the transaction.

cancellationToken CancellationToken

A 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

connection SqlConnection

The connection to transact with.

action Func<SqlTransaction, T>

The handler to execute while a transaction is pending.

cancellationToken CancellationToken

A token that if cancelled will cause this transaction to be aborted or rolled-back.

Returns

T

The value of the action.

Type Parameters

T

The 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

connection SqlConnection

The connection to transact with.

action Action<SqlTransaction>

The handler to execute while a transaction is pending.

cancellationToken CancellationToken

A 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

connection SqlConnection

The connection to transact with.

isolationLevel IsolationLevel

The isolation level for the transaction.

cancellationToken CancellationToken

A token that if cancelled will cause this transaction to be aborted or rolled-back.

action Func<SqlTransaction, T>

The handler to execute while a transaction is pending.

Returns

T

The value of the action.

Type Parameters

T

The 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

connection SqlConnection

The connection to transact with.

isolationLevel IsolationLevel

The isolation level for the transaction.

cancellationToken CancellationToken

A token that if cancelled will cause this transaction to be aborted or rolled-back.

action Action<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

connection SqlConnection

The connection to transact with.

isolationLevel IsolationLevel

The isolation level for the transaction.

action Func<SqlTransaction, T>

The handler to execute while a transaction is pending.

cancellationToken CancellationToken

An optional token that if cancelled will cause this transaction to be aborted or rolled-back.

Returns

T

The value of the action.

Type Parameters

T

The 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

connection SqlConnection

The connection to transact with.

isolationLevel IsolationLevel

The isolation level for the transaction.

action Action<SqlTransaction>

The handler to execute while a transaction is pending.

cancellationToken CancellationToken

An 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

connection SqlConnection

The connection to transact with.

cancellationToken CancellationToken

A token that if cancelled will cause this transaction to be aborted or rolled-back.

action Func<SqlTransaction, T>

The handler to execute while a transaction is pending.

Returns

T

The value of the action.

Type Parameters

T

The 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

connection SqlConnection

The connection to transact with.

cancellationToken CancellationToken

A token that if cancelled will cause this transaction to be aborted or rolled-back.

action Action<SqlTransaction>

The handler to execute while a transaction is pending.