Click or drag to resize

IClientSessionWithTransactionTResult Method

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

Namespace:  MongoDB.Driver
Assembly:  MongoDB.Driver (in MongoDB.Driver.dll) Version: 2.14.0+2b37a1fe1cbdbe1a020b52b77f1197b6d77575e7
Syntax
TResult WithTransaction<TResult>(
	Func<IClientSessionHandle, CancellationToken, TResult> callback,
	TransactionOptions transactionOptions = null,
	CancellationToken cancellationToken = default
)

Parameters

callback
Type: SystemFuncIClientSessionHandle, CancellationToken, TResult
The user defined callback.
transactionOptions (Optional)
Type: MongoDB.DriverTransactionOptions
The transaction options.
cancellationToken (Optional)
Type: System.ThreadingCancellationToken
The cancellation token.

Type Parameters

TResult
The type of callback result.

Return Value

Type: TResult
The callback result.
See Also