Click or drag to resize
MongoCursor Class
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.
Inheritance Hierarchy

Namespace: MongoDB.Driver
Assembly: MongoDB.Driver.Legacy (in MongoDB.Driver.Legacy.dll) Version: 2.3.0
Syntax
public abstract class MongoCursor : IEnumerable

The MongoCursor type exposes the following members.

Constructors
  NameDescription
Protected methodMongoCursor(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.
Protected methodMongoCursor(MongoCollection, IMongoQuery, ReadConcern, ReadPreference, IBsonSerializer)
Initializes a new instance of the MongoCursor class.
Top
Properties
  NameDescription
Public propertyBatchSize
Gets or sets the batch size (the number of documents returned per batch).
Public propertyCollection
Gets the collection that is being queried.
Public propertyDatabase
Gets the database that constains the collection that is being queried.
Public propertyFields
Gets or sets the fields that will be returned from the server.
Public propertyFlags
Gets or sets the query flags.
Public propertyIsFrozen
Gets whether the cursor has been frozen to prevent further changes.
Public propertyLimit
Gets or sets the limit on the number of documents to be returned.
Public propertyMaxAwaitTime
Gets or sets the maximum await time for TailableAwait cursors.
Public propertyOptions
Gets or sets the cursor options. See also the individual Set{Option} methods, which are easier to use.
Public propertyQuery
Gets the query that will be sent to the server.
Public propertyReadConcern
Gets the read concern.
Public propertyReadPreference
Gets or sets the read preference.
Public propertySerializer
Gets the serializer.
Public propertyServer
Gets the server that the query will be sent to.
Public propertySkip
Gets or sets the number of documents the server should skip before returning the rest of the documents.
Top
Methods
  NameDescription
Public methodClone(Type)
Creates a clone of the cursor.
Public methodClone(Type, IBsonSerializer)
Creates a clone of the cursor.
Public methodCloneTDocument
Creates a clone of the cursor.
Public methodCloneTDocument(IBsonSerializer)
Creates a clone of the cursor.
Public methodCount
Returns the number of documents that match the query (ignores Skip and Limit, unlike Size which honors them).
Public methodStatic memberCreate(Type, MongoCollection, IMongoQuery, ReadPreference, IBsonSerializer)
Creates a cursor.
Public methodStatic memberCreate(Type, MongoCollection, IMongoQuery, ReadConcern, ReadPreference, IBsonSerializer)
Creates a cursor.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodExplain
Returns an explanation of how the query was executed (instead of the results).
Public methodExplain(Boolean)
Returns an explanation of how the query was executed (instead of the results).
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodIEnumerableGetEnumerator
Gets the non-generic enumerator.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodSetBatchSize
Sets the batch size (the number of documents returned per batch).
Public methodSetFields(String)
Sets the fields that will be returned from the server.
Public methodSetFields(IMongoFields)
Sets the fields that will be returned from the server.
Public methodSetFlags
Sets the query flags.
Public methodSetHint(String)
Sets the index hint for the query.
Public methodSetHint(BsonDocument)
Sets the index hint for the query.
Public methodSetLimit
Sets the limit on the number of documents to be returned.
Public methodSetMax
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).
Public methodSetMaxAwaitTime
Sets the maximum await time for tailable await cursors.
Public methodSetMaxScan
Sets the maximum number of documents to scan.
Public methodSetMaxTime
Sets the maximum time the server should spend on this query.
Public methodSetMin
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).
Public methodSetOption
Sets a cursor option.
Public methodSetOptions
Sets multiple cursor options. See also the individual Set{Option} methods, which are easier to use.
Public methodSetReadPreference
Sets the read preference.
Public methodSetSerializer
Sets the serializer.
Public methodSetShowDiskLoc
Sets the $showDiskLoc option.
Public methodSetSkip
Sets the number of documents the server should skip before returning the rest of the documents.
Public methodSetSnapshot
Sets the $snapshot option.
Public methodSetSortOrder(String)
Sets the sort order for the server to sort the documents by before returning them.
Public methodSetSortOrder(IMongoSortBy)
Sets the sort order for the server to sort the documents by before returning them.
Public methodSize
Returns the size of the result set (honors Skip and Limit, unlike Count which does not).
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodToBson
Serializes an object to a BSON byte array.
(Defined by BsonExtensionMethods.)
Public Extension MethodToBsonDocument
Serializes an object to a BsonDocument.
(Defined by BsonExtensionMethods.)
Public Extension MethodToJson
Serializes an object to a JSON string.
(Defined by BsonExtensionMethods.)
Top
See Also