Table of Contents

Method WithTransaction

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

WithTransaction<TResult>(Func<IClientSessionHandle, CancellationToken, TResult>, TransactionOptions, CancellationToken)

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

TResult WithTransaction<TResult>(Func<IClientSessionHandle, CancellationToken, TResult> callback, TransactionOptions transactionOptions = null, CancellationToken cancellationToken = default)

Parameters

callback Func<IClientSessionHandle, CancellationToken, TResult>

The user defined callback.

transactionOptions TransactionOptions

The transaction options.

cancellationToken CancellationToken

The cancellation token.

Returns

TResult

The callback result.

Type Parameters

TResult

The type of callback result.