Class CoreSession
Represents a session.
public sealed class CoreSession : ICoreSession, IDisposable
- Inheritance
-
CoreSession
- Implements
- Inherited Members
Constructors
CoreSession(ICluster, ICoreServerSession, CoreSessionOptions)
Initializes a new instance of the CoreSession class.
[Obsolete("This constructor is deprecated. Avoid using CoreSession directly.")]
public CoreSession(ICluster cluster, ICoreServerSession serverSession, CoreSessionOptions options)
Parameters
cluster
IClusterThe cluster.
serverSession
ICoreServerSessionThe server session.
options
CoreSessionOptionsThe options.
- See Also
Properties
Cluster
Gets the cluster.
public ICluster Cluster { get; }
Property Value
- ICluster
The cluster.
- See Also
ClusterTime
Gets the cluster time.
public BsonDocument ClusterTime { get; }
Property Value
- BsonDocument
The cluster time.
- See Also
CurrentTransaction
Gets the current transaction.
public CoreTransaction CurrentTransaction { get; }
Property Value
- CoreTransaction
The current transaction.
- See Also
Id
Gets the session Id.
public BsonDocument Id { get; }
Property Value
- BsonDocument
The session Id.
- See Also
IsCausallyConsistent
Gets a value indicate whether this instance is causally consistent.
public bool IsCausallyConsistent { get; }
Property Value
- bool
true
if the session is causally consistent.
- See Also
IsDirty
Gets a value indicate whether this session is dirty.
public bool IsDirty { get; }
Property Value
- bool
true
if the session is dirty.
- See Also
IsImplicit
Gets a value indicating whether this instance is implicit session.
public bool IsImplicit { get; }
Property Value
- bool
true
if this instance is implicit session; otherwise,false
.
- See Also
IsInTransaction
Gets a value indicating whether this instance is in a transaction.
public bool IsInTransaction { get; }
Property Value
- bool
true
if this instance is in a transaction; otherwise,false
.
- See Also
IsSnapshot
Gets a value indicate whether this instance is a snapshot session.
public bool IsSnapshot { get; }
Property Value
- bool
true
if the session is a snapshot session.
- See Also
OperationTime
Gets the operation time.
public BsonTimestamp OperationTime { get; }
Property Value
- BsonTimestamp
The operation time.
- See Also
Options
Gets the session options.
public CoreSessionOptions Options { get; }
Property Value
- CoreSessionOptions
The session options.
- See Also
ServerSession
Gets the server session.
public ICoreServerSession ServerSession { get; }
Property Value
- ICoreServerSession
The server session.
- See Also
SnapshotTime
Gets the snapshot time.
public BsonTimestamp SnapshotTime { get; }
Property Value
- BsonTimestamp
The snapshot time.
- See Also
Methods
AbortTransaction(CancellationToken)
Aborts the transaction.
public void AbortTransaction(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenThe cancellation token.
- See Also
AbortTransactionAsync(CancellationToken)
Aborts the transaction.
public Task AbortTransactionAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task
A Task.
- See Also
AboutToSendCommand()
The driver is about to send a command on this session. Called to track session state.
public void AboutToSendCommand()
- See Also
AdvanceClusterTime(BsonDocument)
Advances the cluster time.
public void AdvanceClusterTime(BsonDocument newClusterTime)
Parameters
newClusterTime
BsonDocumentThe new cluster time.
- See Also
AdvanceOperationTime(BsonTimestamp)
Advances the operation time.
public void AdvanceOperationTime(BsonTimestamp newOperationTime)
Parameters
newOperationTime
BsonTimestampThe new operation time.
- See Also
AdvanceTransactionNumber()
Advances the transaction id.
public long AdvanceTransactionNumber()
Returns
- long
The transaction id.
- See Also
CommitTransaction(CancellationToken)
Commits the transaction.
public void CommitTransaction(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenThe cancellation token.
- See Also
CommitTransactionAsync(CancellationToken)
Commits the transaction.
public Task CommitTransactionAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task
A Task.
- See Also
Dispose()
public void Dispose()
- See Also
MarkDirty()
Marks the session as dirty.
public void MarkDirty()
- See Also
SetSnapshotTimeIfNeeded(BsonTimestamp)
Sets the snapshot time if not set.
public void SetSnapshotTimeIfNeeded(BsonTimestamp snapshotTime)
Parameters
snapshotTime
BsonTimestampThe snapshot time.
- See Also
StartTransaction(TransactionOptions)
Starts a transaction.
public void StartTransaction(TransactionOptions transactionOptions = null)
Parameters
transactionOptions
TransactionOptionsThe transaction options.
- See Also
WasUsed()
Called by the driver when the session is used (i.e. sent to the server).
public void WasUsed()
- See Also