Table of Contents

Class MongoCursor<TDocument>

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.Legacy.dll

An object that can be enumerated to fetch the results of a query. The query is not sent to the server until you begin enumerating the results.

public class MongoCursor<TDocument> : MongoCursor, IEnumerable<TDocument>, IEnumerable

Type Parameters

TDocument

The type of the documents returned.

Inheritance
MongoCursor<TDocument>
Implements
IEnumerable<TDocument>
Inherited Members
Extension Methods

Constructors

MongoCursor(MongoCollection, IMongoQuery, ReadConcern, ReadPreference, IBsonSerializer)

Initializes a new instance of the MongoCursor<TDocument> class.

MongoCursor(MongoCollection, IMongoQuery, ReadPreference, IBsonSerializer)

Creates a new MongoCursor. It is very unlikely that you will call this constructor. Instead, see all the Find methods in MongoCollection.

Properties

Serializer

Gets the serializer.

Methods

CreateExplainOperation(ExplainVerbosity)

Creates an explain operation for this cursor.

GetEnumerator()

Returns an enumerator that can be used to enumerate the cursor. Normally you will use the foreach statement to enumerate the cursor (foreach will call GetEnumerator for you).

IEnumerableGetEnumerator()

Gets the non-generic enumerator.

SetBatchSize(int)

Sets the batch size (the number of documents returned per batch).

SetCollation(Collation)

Sets the collation.

SetFields(IMongoFields)

Sets the fields that will be returned from the server.

SetFields(params string[])

Sets the fields that will be returned from the server.

SetFlags(QueryFlags)

Sets the query flags.

SetHint(BsonDocument)

Sets the index hint for the query.

SetHint(string)

Sets the index hint for the query.

SetLimit(int)

Sets the limit on the number of documents to be returned.

SetMax(BsonDocument)

Sets the max value for the index key range of documents to return (note: the max value itself is excluded from the range). Often combined with SetHint (if SetHint is not used the server will attempt to determine the matching index automatically).

SetMaxAwaitTime(TimeSpan?)

Sets the maximum await time for tailable await cursors.

SetMaxScan(int)

Sets the maximum number of documents to scan.

SetMaxTime(TimeSpan)

Sets the maximum time the server should spend on this query.

SetMin(BsonDocument)

Sets the min value for the index key range of documents to return (note: the min value itself is included in the range). Often combined with SetHint (if SetHint is not used the server will attempt to determine the matching index automatically).

SetOption(string, BsonValue)

Sets a cursor option.

SetOptions(BsonDocument)

Sets multiple cursor options. See also the individual Set{Option} methods, which are easier to use.

SetReadPreference(ReadPreference)

Sets the read preference.

SetSerializer(IBsonSerializer<TDocument>)

Sets the serializer.

SetShowDiskLoc()

Sets the $showDiskLoc option.

SetSkip(int)

Sets the number of documents the server should skip before returning the rest of the documents.

SetSnapshot()

Sets the $snapshot option.

SetSortOrder(IMongoSortBy)

Sets the sort order for the server to sort the documents by before returning them.

SetSortOrder(params string[])

Sets the sort order for the server to sort the documents by before returning them.