Table of Contents

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

connection SqlConnection

The connection to transact with.

action Func<SqlTransaction, ValueTask<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

ValueTask<T>

The value of the awaited action.

Type Parameters

T

The 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

connection SqlConnection

The connection to transact with.

action Func<SqlTransaction, ValueTask>

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

ValueTask

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

connection SqlConnection

The connection to transact with.

action Func<SqlTransaction, ValueTask<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

ValueTask<T>

The value of the awaited action.

Type Parameters

T

The 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

connection SqlConnection

The connection to transact with.

action Func<SqlTransaction, ValueTask>

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

ValueTask

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

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, ValueTask<T>>

The handler to execute while a transaction is pending.

Returns

ValueTask<T>

The value of the awaited action.

Type Parameters

T

The 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

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, ValueTask>

The handler to execute while a transaction is pending.

Returns

ValueTask

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

connection SqlConnection

The connection to transact with.

isolationLevel IsolationLevel

The isolation level for the transaction.

action Func<SqlTransaction, ValueTask<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

ValueTask<T>

The value of the awaited action.

Type Parameters

T

The 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

connection SqlConnection

The connection to transact with.

isolationLevel IsolationLevel

The isolation level for the transaction.

action Func<SqlTransaction, ValueTask>

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

ValueTask

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

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, ValueTask<T>>

The handler to execute while a transaction is pending.

Returns

ValueTask<T>

The value of the awaited action.

Type Parameters

T

The 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

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, ValueTask>

The handler to execute while a transaction is pending.

Returns

ValueTask