Click or drag to resize

MongoCollection Class

Represents a MongoDB collection and the settings used to access it. This class is thread-safe.
Inheritance Hierarchy

Namespace:  MongoDB.Driver
Assembly:  MongoDB.Driver.Legacy (in MongoDB.Driver.Legacy.dll) Version: 2.17.0+b316340e6cc3a8bfc8638dc31b54fbbfe41bfcb2
Syntax
public abstract class MongoCollection

The MongoCollection type exposes the following members.

Constructors
  NameDescription
Protected methodMongoCollection
Protected constructor for abstract base class.
Top
Properties
  NameDescription
Public propertyDatabase
Gets the database that contains this collection.
Public propertyFullName
Gets the fully qualified name of this collection.
Public propertyName
Gets the name of this collection.
Public propertySettings
Gets the settings being used to access this collection.
Top
Methods
  NameDescription
Public methodAggregate
Represents an aggregate framework query. The command is not sent to the server until the result is enumerated.
Public methodAggregateExplain
Runs an aggregate command with explain set and returns the explain result.
Public methodCount
Counts the number of documents in this collection.
Public methodCount(CountArgs)
Counts the number of documents in this collection that match a query.
Public methodCount(IMongoQuery)
Counts the number of documents in this collection that match a query.
Public methodCreateIndex(IMongoIndexKeys)
Creates an index for this collection.
Public methodCreateIndex(String)
Creates an index for this collection.
Public methodCreateIndex(IMongoIndexKeys, IMongoIndexOptions)
Creates an index for this collection.
Public methodDistinct(String)
Returns the distinct values for a given field.
Public methodDistinct(String, IMongoQuery)
Returns the distinct values for a given field for documents that match a query.
Public methodDistinctTValue(DistinctArgs)
Returns the distinct values for a given field.
Public methodDistinctTValue(String)
Returns the distinct values for a given field.
Public methodDistinctTValue(String, IMongoQuery)
Returns the distinct values for a given field for documents that match a query.
Public methodDrop
Drops this collection.
Public methodDropAllIndexes
Drops all indexes on this collection.
Public methodDropIndex(IMongoIndexKeys)
Drops an index on this collection.
Public methodDropIndex(String)
Drops an index on this collection.
Public methodDropIndexByName
Drops an index on this collection.
Public methodEnsureIndex(IMongoIndexKeys) Obsolete.
Ensures that the desired index exists and creates it if it does not.
Public methodEnsureIndex(String) Obsolete.
Ensures that the desired index exists and creates it if it does not.
Public methodEnsureIndex(IMongoIndexKeys, IMongoIndexOptions) Obsolete.
Ensures that the desired index exists and creates it if it does not.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodExists
Tests whether this collection exists.
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 methodFindAllAs(Type)
Returns a cursor that can be used to find all documents in this collection as TDocuments.
Public methodFindAllAsTDocument
Returns a cursor that can be used to find all documents in this collection as TDocuments.
Public methodFindAndModify(FindAndModifyArgs)
Finds one matching document using the supplied arguments and applies the specified update to it.
Public methodFindAndModify(IMongoQuery, IMongoSortBy, IMongoUpdate) Obsolete.
Finds one matching document using the query and sortBy parameters and applies the specified update to it.
Public methodFindAndModify(IMongoQuery, IMongoSortBy, IMongoUpdate, Boolean) Obsolete.
Finds one matching document using the query and sortBy parameters and applies the specified update to it.
Public methodFindAndModify(IMongoQuery, IMongoSortBy, IMongoUpdate, Boolean, Boolean) Obsolete.
Finds one matching document using the query and sortBy parameters and applies the specified update to it.
Public methodFindAndModify(IMongoQuery, IMongoSortBy, IMongoUpdate, IMongoFields, Boolean, Boolean) Obsolete.
Finds one matching document using the query and sortBy parameters and applies the specified update to it.
Public methodFindAndRemove(FindAndRemoveArgs)
Finds one matching document using the supplied args and removes it from this collection.
Public methodFindAndRemove(IMongoQuery, IMongoSortBy) Obsolete.
Finds one matching document using the query and sortBy parameters and removes it from this collection.
Public methodFindAs(Type, IMongoQuery)
Returns a cursor that can be used to find all documents in this collection that match the query as TDocuments.
Public methodFindAsTDocument(IMongoQuery)
Returns a cursor that can be used to find all documents in this collection that match the query as TDocuments.
Public methodFindOneAs(Type)
Returns one document in this collection as a TDocument.
Public methodFindOneAs(Type, FindOneArgs)
Returns one document in this collection as a TDocument.
Public methodFindOneAs(Type, IMongoQuery)
Returns one document in this collection that matches a query as a TDocument.
Public methodFindOneAsTDocument
Returns one document in this collection as a TDocument.
Public methodFindOneAsTDocument(FindOneArgs)
Returns one document in this collection as a TDocument.
Public methodFindOneAsTDocument(IMongoQuery)
Returns one document in this collection that matches a query as a TDocument.
Public methodFindOneByIdAs(Type, BsonValue)
Returns a cursor that can be used to find one document in this collection by its _id value as a TDocument.
Public methodFindOneByIdAsTDocument(BsonValue)
Returns a cursor that can be used to find one document in this collection by its _id value as a TDocument.
Public methodGeoHaystackSearchAs(Type, GeoHaystackSearchArgs) Obsolete.
Runs a geoHaystack search command on this collection.
Public methodGeoHaystackSearchAs(Type, Double, Double, IMongoGeoHaystackSearchOptions) Obsolete.
Runs a geoHaystack search command on this collection.
Public methodGeoHaystackSearchAsTDocument(GeoHaystackSearchArgs) Obsolete.
Runs a geoHaystack search command on this collection.
Public methodGeoHaystackSearchAsTDocument(Double, Double, IMongoGeoHaystackSearchOptions) Obsolete.
Runs a geoHaystack search command on this collection.
Public methodGeoNearAs(Type, GeoNearArgs)
Runs a GeoNear command on this collection.
Public methodGeoNearAs(Type, IMongoQuery, Double, Double, Int32) Obsolete.
Runs a GeoNear command on this collection.
Public methodGeoNearAs(Type, IMongoQuery, Double, Double, Int32, IMongoGeoNearOptions) Obsolete.
Runs a GeoNear command on this collection.
Public methodGeoNearAsTDocument(GeoNearArgs)
Runs a GeoNear command on this collection.
Public methodGeoNearAsTDocument(IMongoQuery, Double, Double, Int32) Obsolete.
Runs a GeoNear command on this collection.
Public methodGeoNearAsTDocument(IMongoQuery, Double, Double, Int32, IMongoGeoNearOptions) Obsolete.
Runs a GeoNear command on this collection.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetIndexes
Gets the indexes for this collection.
Public methodGetStats
Gets the stats for this collection.
Public methodGetStats(GetStatsArgs)
Gets the stats for this collection.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGroup(GroupArgs) Obsolete.
Runs the group command on this collection.
Public methodGroup(IMongoQuery, BsonJavaScript, BsonDocument, BsonJavaScript, BsonJavaScript) Obsolete.
Runs the group command on this collection.
Public methodGroup(IMongoQuery, IMongoGroupBy, BsonDocument, BsonJavaScript, BsonJavaScript) Obsolete.
Runs the group command on this collection.
Public methodGroup(IMongoQuery, String, BsonDocument, BsonJavaScript, BsonJavaScript) Obsolete.
Runs the group command on this collection.
Public methodIndexExists(IMongoIndexKeys)
Tests whether an index exists.
Public methodIndexExists(String)
Tests whether an index exists.
Public methodIndexExistsByName
Tests whether an index exists.
Public methodInitializeOrderedBulkOperationAsTDocument
Creates a fluent builder for an ordered bulk operation.
Public methodInitializeUnorderedBulkOperationAsTDocument
Creates a fluent builder for an unordered bulk operation.
Public methodInsert(Type, Object)
Inserts a document into this collection (see also InsertBatch to insert multiple documents at once).
Public methodInsert(Type, Object, MongoInsertOptions)
Inserts a document into this collection (see also InsertBatch to insert multiple documents at once).
Public methodInsert(Type, Object, WriteConcern)
Inserts a document into this collection (see also InsertBatch to insert multiple documents at once).
Public methodInsertTNominalType(TNominalType)
Inserts a document into this collection (see also InsertBatch to insert multiple documents at once).
Public methodInsertTNominalType(TNominalType, MongoInsertOptions)
Inserts a document into this collection (see also InsertBatch to insert multiple documents at once).
Public methodInsertTNominalType(TNominalType, WriteConcern)
Inserts a document into this collection (see also InsertBatch to insert multiple documents at once).
Public methodInsertBatch(Type, IEnumerable)
Inserts multiple documents at once into this collection (see also Insert to insert a single document).
Public methodInsertBatch(Type, IEnumerable, MongoInsertOptions)
Inserts multiple documents at once into this collection (see also Insert to insert a single document).
Public methodInsertBatch(Type, IEnumerable, WriteConcern)
Inserts multiple documents at once into this collection (see also Insert to insert a single document).
Public methodInsertBatchTNominalType(IEnumerableTNominalType)
Inserts multiple documents at once into this collection (see also Insert to insert a single document).
Public methodInsertBatchTNominalType(IEnumerableTNominalType, MongoInsertOptions)
Inserts multiple documents at once into this collection (see also Insert to insert a single document).
Public methodInsertBatchTNominalType(IEnumerableTNominalType, WriteConcern)
Inserts multiple documents at once into this collection (see also Insert to insert a single document).
Public methodIsCapped
Tests whether this collection is capped.
Public methodMapReduce Obsolete.
Runs a map-reduce command on this collection.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodParallelScanAs(Type, ParallelScanArgs) Obsolete.
Scans an entire collection in parallel using multiple cursors.
Public methodParallelScanAsTDocument(ParallelScanArgsTDocument) Obsolete.
Scans an entire collection in parallel using multiple cursors.
Public methodReIndex Obsolete.
Runs the ReIndex command on this collection.
Public methodRemove(IMongoQuery)
Removes documents from this collection that match a query.
Public methodRemove(RemoveArgs)
Removes documents from this collection that match a query.
Public methodRemove(IMongoQuery, RemoveFlags)
Removes documents from this collection that match a query.
Public methodRemove(IMongoQuery, WriteConcern)
Removes documents from this collection that match a query.
Public methodRemove(IMongoQuery, RemoveFlags, WriteConcern)
Removes documents from this collection that match a query.
Public methodRemoveAll
Removes all documents from this collection (see also Drop).
Public methodRemoveAll(WriteConcern)
Removes all documents from this collection (see also Drop).
Public methodSave(Type, Object)
Saves a document to this collection. The document must have an identifiable Id field. Based on the value of the Id field Save will perform either an Insert or an Update.
Public methodSave(Type, Object, MongoInsertOptions)
Saves a document to this collection. The document must have an identifiable Id field. Based on the value of the Id field Save will perform either an Insert or an Update.
Public methodSave(Type, Object, WriteConcern)
Saves a document to this collection. The document must have an identifiable Id field. Based on the value of the Id field Save will perform either an Insert or an Update.
Public methodSaveTNominalType(TNominalType)
Saves a document to this collection. The document must have an identifiable Id field. Based on the value of the Id field Save will perform either an Insert or an Update.
Public methodSaveTNominalType(TNominalType, MongoInsertOptions)
Saves a document to this collection. The document must have an identifiable Id field. Based on the value of the Id field Save will perform either an Insert or an Update.
Public methodSaveTNominalType(TNominalType, WriteConcern)
Saves a document to this collection. The document must have an identifiable Id field. Based on the value of the Id field Save will perform either an Insert or an Update.
Public methodToString
Gets a canonical string representation for this database.
(Overrides ObjectToString.)
Public methodUpdate(IMongoQuery, IMongoUpdate)
Updates one matching document in this collection.
Public methodUpdate(IMongoQuery, IMongoUpdate, MongoUpdateOptions)
Updates one or more matching documents in this collection (for multiple updates use UpdateFlags.Multi).
Public methodUpdate(IMongoQuery, IMongoUpdate, UpdateFlags)
Updates one or more matching documents in this collection (for multiple updates use UpdateFlags.Multi).
Public methodUpdate(IMongoQuery, IMongoUpdate, WriteConcern)
Updates one matching document in this collection.
Public methodUpdate(IMongoQuery, IMongoUpdate, UpdateFlags, WriteConcern)
Updates one or more matching documents in this collection (for multiple updates use UpdateFlags.Multi).
Public methodValidate
Validates the integrity of this collection.
Public methodValidate(ValidateCollectionArgs)
Validates the integrity of this collection.
Top
Extension Methods
  NameDescription
Public Extension MethodAsQueryableT
Returns an instance of IQueryable{{T}} for a MongoCollection.
(Defined by LinqExtensionMethods.)
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