Table of Contents

Method Query

Namespace
MongoDB.Driver.Core.Bindings
Assembly
MongoDB.Driver.Core.dll

Query<TDocument>(CollectionNamespace, BsonDocument, BsonDocument, IElementNameValidator, int, int, bool, bool, bool, bool, bool, IBsonSerializer<TDocument>, MessageEncoderSettings, CancellationToken)

Executes a Query protocol.

CursorBatch<TDocument> Query<TDocument>(CollectionNamespace collectionNamespace, BsonDocument query, BsonDocument fields, IElementNameValidator queryValidator, int skip, int batchSize, bool secondaryOk, bool partialOk, bool noCursorTimeout, bool tailableCursor, bool awaitData, IBsonSerializer<TDocument> serializer, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)

Parameters

collectionNamespace CollectionNamespace

The collection namespace.

query BsonDocument

The query.

fields BsonDocument

The fields.

queryValidator IElementNameValidator

The query validator.

skip int

The number of documents to skip.

batchSize int

The size of a batch.

secondaryOk bool

if set to true sets the SecondaryOk bit to true in the query message sent to the server.

partialOk bool

if set to true the server is allowed to return partial results if any shards are unavailable.

noCursorTimeout bool

if set to true the server will not timeout the cursor.

tailableCursor bool

if set to true the query should return a tailable cursor.

awaitData bool

if set to true the server should await awhile before returning an empty batch for a tailable cursor.

serializer IBsonSerializer<TDocument>

The serializer.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

cancellationToken CancellationToken

The cancellation token.

Returns

CursorBatch<TDocument>

The result of the Insert protocol.

Type Parameters

TDocument

The type of the document.

Query<TDocument>(CollectionNamespace, BsonDocument, BsonDocument, IElementNameValidator, int, int, bool, bool, bool, bool, bool, bool, IBsonSerializer<TDocument>, MessageEncoderSettings, CancellationToken)

Executes a Query protocol.

[Obsolete("Use an overload that does not have an oplogReplay parameter instead.")]
CursorBatch<TDocument> Query<TDocument>(CollectionNamespace collectionNamespace, BsonDocument query, BsonDocument fields, IElementNameValidator queryValidator, int skip, int batchSize, bool secondaryOk, bool partialOk, bool noCursorTimeout, bool oplogReplay, bool tailableCursor, bool awaitData, IBsonSerializer<TDocument> serializer, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)

Parameters

collectionNamespace CollectionNamespace

The collection namespace.

query BsonDocument

The query.

fields BsonDocument

The fields.

queryValidator IElementNameValidator

The query validator.

skip int

The number of documents to skip.

batchSize int

The size of a batch.

secondaryOk bool

if set to true sets the SecondaryOk bit to true in the query message sent to the server.

partialOk bool

if set to true the server is allowed to return partial results if any shards are unavailable.

noCursorTimeout bool

if set to true the server will not timeout the cursor.

oplogReplay bool

if set to true the OplogReplay bit will be set.

tailableCursor bool

if set to true the query should return a tailable cursor.

awaitData bool

if set to true the server should await awhile before returning an empty batch for a tailable cursor.

serializer IBsonSerializer<TDocument>

The serializer.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

cancellationToken CancellationToken

The cancellation token.

Returns

CursorBatch<TDocument>

The result of the Insert protocol.

Type Parameters

TDocument

The type of the document.