Class AsyncCursor<TDocument>
- Namespace
- MongoDB.Driver.Core.Operations
- Assembly
- MongoDB.Driver.Core.dll
Represents an async cursor.
public class AsyncCursor<TDocument> : IAsyncCursor<TDocument>, IDisposable
Type Parameters
TDocumentThe type of the documents.
- Inheritance
-
AsyncCursor<TDocument>
- Implements
-
IAsyncCursor<TDocument>
- Inherited Members
- Extension Methods
Constructors
AsyncCursor(IChannelSource, CollectionNamespace, BsonDocument, IReadOnlyList<TDocument>, long, BsonDocument, int?, int?, IBsonSerializer<TDocument>, MessageEncoderSettings, TimeSpan?)
Initializes a new instance of the AsyncCursor<TDocument> class.
[Obsolete("Use overload without query.")]
public AsyncCursor(IChannelSource channelSource, CollectionNamespace collectionNamespace, BsonDocument query, IReadOnlyList<TDocument> firstBatch, long cursorId, BsonDocument postBatchResumeToken, int? batchSize, int? limit, IBsonSerializer<TDocument> serializer, MessageEncoderSettings messageEncoderSettings, TimeSpan? maxTime)
Parameters
channelSourceIChannelSourceThe channel source.
collectionNamespaceCollectionNamespaceThe collection namespace.
queryBsonDocumentThe query.
firstBatchIReadOnlyList<TDocument>The first batch.
cursorIdlongThe cursor identifier.
postBatchResumeTokenBsonDocumentThe post batch resume token.
batchSizeint?The size of a batch.
limitint?The limit.
serializerIBsonSerializer<TDocument>The serializer.
messageEncoderSettingsMessageEncoderSettingsThe message encoder settings.
maxTimeTimeSpan?The maxTime for each batch.
AsyncCursor(IChannelSource, CollectionNamespace, BsonDocument, IReadOnlyList<TDocument>, long, int?, int?, IBsonSerializer<TDocument>, MessageEncoderSettings, TimeSpan?)
Initializes a new instance of the AsyncCursor<TDocument> class.
[Obsolete("Use overload without query.")]
public AsyncCursor(IChannelSource channelSource, CollectionNamespace collectionNamespace, BsonDocument query, IReadOnlyList<TDocument> firstBatch, long cursorId, int? batchSize, int? limit, IBsonSerializer<TDocument> serializer, MessageEncoderSettings messageEncoderSettings, TimeSpan? maxTime = null)
Parameters
channelSourceIChannelSourceThe channel source.
collectionNamespaceCollectionNamespaceThe collection namespace.
queryBsonDocumentThe query.
firstBatchIReadOnlyList<TDocument>The first batch.
cursorIdlongThe cursor identifier.
batchSizeint?The size of a batch.
limitint?The limit.
serializerIBsonSerializer<TDocument>The serializer.
messageEncoderSettingsMessageEncoderSettingsThe message encoder settings.
maxTimeTimeSpan?The maxTime for each batch.
AsyncCursor(IChannelSource, CollectionNamespace, BsonValue, IReadOnlyList<TDocument>, long, BsonDocument, int?, int?, IBsonSerializer<TDocument>, MessageEncoderSettings, TimeSpan?)
Initializes a new instance of the AsyncCursor<TDocument> class.
public AsyncCursor(IChannelSource channelSource, CollectionNamespace collectionNamespace, BsonValue comment, IReadOnlyList<TDocument> firstBatch, long cursorId, BsonDocument postBatchResumeToken, int? batchSize, int? limit, IBsonSerializer<TDocument> serializer, MessageEncoderSettings messageEncoderSettings, TimeSpan? maxTime)
Parameters
channelSourceIChannelSourceThe channel source.
collectionNamespaceCollectionNamespaceThe collection namespace.
commentBsonValueThe comment.
firstBatchIReadOnlyList<TDocument>The first batch.
cursorIdlongThe cursor identifier.
postBatchResumeTokenBsonDocumentThe post batch resume token.
batchSizeint?The size of a batch.
limitint?The limit.
serializerIBsonSerializer<TDocument>The serializer.
messageEncoderSettingsMessageEncoderSettingsThe message encoder settings.
maxTimeTimeSpan?The maxTime for each batch.
AsyncCursor(IChannelSource, CollectionNamespace, BsonValue, IReadOnlyList<TDocument>, long, int?, int?, IBsonSerializer<TDocument>, MessageEncoderSettings, TimeSpan?)
Initializes a new instance of the AsyncCursor<TDocument> class.
public AsyncCursor(IChannelSource channelSource, CollectionNamespace collectionNamespace, BsonValue comment, IReadOnlyList<TDocument> firstBatch, long cursorId, int? batchSize, int? limit, IBsonSerializer<TDocument> serializer, MessageEncoderSettings messageEncoderSettings, TimeSpan? maxTime = null)
Parameters
channelSourceIChannelSourceThe channel source.
collectionNamespaceCollectionNamespaceThe collection namespace.
commentBsonValueThe comment.
firstBatchIReadOnlyList<TDocument>The first batch.
cursorIdlongThe cursor identifier.
batchSizeint?The size of a batch.
limitint?The limit.
serializerIBsonSerializer<TDocument>The serializer.
messageEncoderSettingsMessageEncoderSettingsThe message encoder settings.
maxTimeTimeSpan?The maxTime for each batch.
Properties
Current
Gets the current batch of documents.
public IEnumerable<TDocument> Current { get; }
Property Value
- IEnumerable<TDocument>
The current batch of documents.
PostBatchResumeToken
Gets the post batch resume token.
public BsonDocument PostBatchResumeToken { get; }
Property Value
- BsonDocument
The post batch resume token.
WasFirstBatchEmpty
Gets a value indicating whether the first batch was empty or not.
public bool WasFirstBatchEmpty { get; }
Property Value
- bool
trueif the first batch was empty; otherwise,false.
Methods
Close(CancellationToken)
Closes the cursor.
public void Close(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
CloseAsync(CancellationToken)
Closes the cursor.
public Task CloseAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task
A task.
Dispose()
public void Dispose()
Dispose(bool)
Releases unmanaged and - optionally - managed resources.
protected virtual void Dispose(bool disposing)
Parameters
disposingbooltrueto release both managed and unmanaged resources;falseto release only unmanaged resources.
MoveNext(CancellationToken)
Moves to the next batch of documents.
public bool MoveNext(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
Returns
- bool
Whether any more documents are available.
MoveNextAsync(CancellationToken)
Moves to the next batch of documents.
public Task<bool> MoveNextAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation token.