Table of Contents

Method WithTransactionAsync

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

WithTransactionAsync<TResult>(Func<IClientSessionHandle, CancellationToken, Task<TResult>>, TransactionOptions, CancellationToken)

Executes a callback within a transaction, with retries if needed.

Task<TResult> WithTransactionAsync<TResult>(Func<IClientSessionHandle, CancellationToken, Task<TResult>> callbackAsync, TransactionOptions transactionOptions = null, CancellationToken cancellationToken = default)

Parameters

callbackAsync Func<IClientSessionHandle, CancellationToken, Task<TResult>>

The user defined callback.

transactionOptions TransactionOptions

The transaction options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<TResult>

The callback result.

Type Parameters

TResult

The type of callback result.