Method WithTransaction
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
TransactionOptionsThe transaction options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- TResult
The callback result.
Type Parameters
TResult
The type of callback result.