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