Interface IClientSession
The interface for a client session.
public interface IClientSession : IDisposable
- Inherited Members
Properties
Client
Gets the client.
IMongoClient Client { get; }
Property Value
- IMongoClient
The client.
ClusterTime
Gets the cluster time.
BsonDocument ClusterTime { get; }
Property Value
- BsonDocument
The cluster time.
IsImplicit
Gets a value indicating whether this session is an implicit session.
bool IsImplicit { get; }
Property Value
- bool
trueif this session is an implicit session; otherwise,false.
IsInTransaction
Gets a value indicating whether this instance is in a transaction.
bool IsInTransaction { get; }
Property Value
- bool
trueif this instance is in a transaction; otherwise,false.
OperationTime
Gets the operation time.
BsonTimestamp OperationTime { get; }
Property Value
- BsonTimestamp
The operation time.
Options
Gets the options.
ClientSessionOptions Options { get; }
Property Value
- ClientSessionOptions
The options.
ServerSession
Gets the server session.
IServerSession ServerSession { get; }
Property Value
- IServerSession
The server session.
WrappedCoreSession
Gets the wrapped core session (intended for internal use only).
ICoreSessionHandle WrappedCoreSession { get; }
Property Value
- ICoreSessionHandle
The wrapped core session.
Methods
AbortTransaction(CancellationToken)
Aborts the transaction.
void AbortTransaction(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
AbortTransactionAsync(CancellationToken)
Aborts the transaction.
Task AbortTransactionAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task
A Task.
AdvanceClusterTime(BsonDocument)
Advances the cluster time.
void AdvanceClusterTime(BsonDocument newClusterTime)
Parameters
newClusterTimeBsonDocumentThe new cluster time.
AdvanceOperationTime(BsonTimestamp)
Advances the operation time.
void AdvanceOperationTime(BsonTimestamp newOperationTime)
Parameters
newOperationTimeBsonTimestampThe new operation time.
CommitTransaction(CancellationToken)
Commits the transaction.
void CommitTransaction(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
CommitTransactionAsync(CancellationToken)
Commits the transaction.
Task CommitTransactionAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task
A Task.
StartTransaction(TransactionOptions)
Starts a transaction.
void StartTransaction(TransactionOptions transactionOptions = null)
Parameters
transactionOptionsTransactionOptionsThe transaction options.
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
callbackAsyncFunc<IClientSessionHandle, CancellationToken, Task<TResult>>The user defined callback.
transactionOptionsTransactionOptionsThe transaction options.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<TResult>
The callback result.
Type Parameters
TResultThe type of callback result.
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
callbackFunc<IClientSessionHandle, CancellationToken, TResult>The user defined callback.
transactionOptionsTransactionOptionsThe transaction options.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- TResult
The callback result.
Type Parameters
TResultThe type of callback result.