Table of Contents

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

TDocument

The 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

channelSource IChannelSource

The channel source.

collectionNamespace CollectionNamespace

The collection namespace.

query BsonDocument

The query.

firstBatch IReadOnlyList<TDocument>

The first batch.

cursorId long

The cursor identifier.

postBatchResumeToken BsonDocument

The post batch resume token.

batchSize int?

The size of a batch.

limit int?

The limit.

serializer IBsonSerializer<TDocument>

The serializer.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

maxTime TimeSpan?

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

channelSource IChannelSource

The channel source.

collectionNamespace CollectionNamespace

The collection namespace.

query BsonDocument

The query.

firstBatch IReadOnlyList<TDocument>

The first batch.

cursorId long

The cursor identifier.

batchSize int?

The size of a batch.

limit int?

The limit.

serializer IBsonSerializer<TDocument>

The serializer.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

maxTime TimeSpan?

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

channelSource IChannelSource

The channel source.

collectionNamespace CollectionNamespace

The collection namespace.

comment BsonValue

The comment.

firstBatch IReadOnlyList<TDocument>

The first batch.

cursorId long

The cursor identifier.

postBatchResumeToken BsonDocument

The post batch resume token.

batchSize int?

The size of a batch.

limit int?

The limit.

serializer IBsonSerializer<TDocument>

The serializer.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

maxTime TimeSpan?

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

channelSource IChannelSource

The channel source.

collectionNamespace CollectionNamespace

The collection namespace.

comment BsonValue

The comment.

firstBatch IReadOnlyList<TDocument>

The first batch.

cursorId long

The cursor identifier.

batchSize int?

The size of a batch.

limit int?

The limit.

serializer IBsonSerializer<TDocument>

The serializer.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

maxTime TimeSpan?

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

true if the first batch was empty; otherwise, false.

Methods

Close(CancellationToken)

Closes the cursor.

public void Close(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token.

CloseAsync(CancellationToken)

Closes the cursor.

public Task CloseAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The 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

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

MoveNext(CancellationToken)

Moves to the next batch of documents.

public bool MoveNext(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The 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

cancellationToken CancellationToken

The cancellation token.

Returns

Task<bool>

A Task whose result indicates whether any more documents are available.