Table of Contents

Class MongoCollection

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

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

public abstract class MongoCollection
Inheritance
MongoCollection
Derived
Inherited Members
Extension Methods

Constructors

MongoCollection(MongoDatabase, string, MongoCollectionSettings)

Protected constructor for abstract base class.

Properties

Database

Gets the database that contains this collection.

FullName

Gets the fully qualified name of this collection.

Name

Gets the name of this collection.

Settings

Gets the settings being used to access this collection.

Methods

Aggregate(AggregateArgs)

Represents an aggregate framework query. The command is not sent to the server until the result is enumerated.

AggregateExplain(AggregateArgs)

Runs an aggregate command with explain set and returns the explain result.

Count()

Counts the number of documents in this collection.

Count(CountArgs)

Counts the number of documents in this collection that match a query.

Count(IMongoQuery)

Counts the number of documents in this collection that match a query.

CreateIndex(IMongoIndexKeys)

Creates an index for this collection.

CreateIndex(IMongoIndexKeys, IMongoIndexOptions)

Creates an index for this collection.

CreateIndex(params string[])

Creates an index for this collection.

Distinct(string)

Returns the distinct values for a given field.

Distinct(string, IMongoQuery)

Returns the distinct values for a given field for documents that match a query.

Distinct<TValue>(DistinctArgs)

Returns the distinct values for a given field.

Distinct<TValue>(string)

Returns the distinct values for a given field.

Distinct<TValue>(string, IMongoQuery)

Returns the distinct values for a given field for documents that match a query.

Drop()

Drops this collection.

DropAllIndexes()

Drops all indexes on this collection.

DropIndex(IMongoIndexKeys)

Drops an index on this collection.

DropIndex(params string[])

Drops an index on this collection.

DropIndexByName(string)

Drops an index on this collection.

EnsureIndex(IMongoIndexKeys)

Ensures that the desired index exists and creates it if it does not.

EnsureIndex(IMongoIndexKeys, IMongoIndexOptions)

Ensures that the desired index exists and creates it if it does not.

EnsureIndex(params string[])

Ensures that the desired index exists and creates it if it does not.

Exists()

Tests whether this collection exists.

FindAllAs(Type)

Returns a cursor that can be used to find all documents in this collection as TDocuments.

FindAllAs<TDocument>()

Returns a cursor that can be used to find all documents in this collection as TDocuments.

FindAndModify(FindAndModifyArgs)

Finds one matching document using the supplied arguments and applies the specified update to it.

FindAndModify(IMongoQuery, IMongoSortBy, IMongoUpdate)

Finds one matching document using the query and sortBy parameters and applies the specified update to it.

FindAndModify(IMongoQuery, IMongoSortBy, IMongoUpdate, IMongoFields, bool, bool)

Finds one matching document using the query and sortBy parameters and applies the specified update to it.

FindAndModify(IMongoQuery, IMongoSortBy, IMongoUpdate, bool)

Finds one matching document using the query and sortBy parameters and applies the specified update to it.

FindAndModify(IMongoQuery, IMongoSortBy, IMongoUpdate, bool, bool)

Finds one matching document using the query and sortBy parameters and applies the specified update to it.

FindAndRemove(FindAndRemoveArgs)

Finds one matching document using the supplied args and removes it from this collection.

FindAndRemove(IMongoQuery, IMongoSortBy)

Finds one matching document using the query and sortBy parameters and removes it from this collection.

FindAs(Type, IMongoQuery)

Returns a cursor that can be used to find all documents in this collection that match the query as TDocuments.

FindAs<TDocument>(IMongoQuery)

Returns a cursor that can be used to find all documents in this collection that match the query as TDocuments.

FindOneAs(Type)

Returns one document in this collection as a TDocument.

FindOneAs(Type, FindOneArgs)

Returns one document in this collection as a TDocument.

FindOneAs(Type, IMongoQuery)

Returns one document in this collection that matches a query as a TDocument.

FindOneAs<TDocument>()

Returns one document in this collection as a TDocument.

FindOneAs<TDocument>(FindOneArgs)

Returns one document in this collection as a TDocument.

FindOneAs<TDocument>(IMongoQuery)

Returns one document in this collection that matches a query as a TDocument.

FindOneByIdAs(Type, BsonValue)

Returns a cursor that can be used to find one document in this collection by its _id value as a TDocument.

FindOneByIdAs<TDocument>(BsonValue)

Returns a cursor that can be used to find one document in this collection by its _id value as a TDocument.

GeoHaystackSearchAs(Type, GeoHaystackSearchArgs)

Runs a geoHaystack search command on this collection.

GeoHaystackSearchAs(Type, double, double, IMongoGeoHaystackSearchOptions)

Runs a geoHaystack search command on this collection.

GeoHaystackSearchAs<TDocument>(GeoHaystackSearchArgs)

Runs a geoHaystack search command on this collection.

GeoHaystackSearchAs<TDocument>(double, double, IMongoGeoHaystackSearchOptions)

Runs a geoHaystack search command on this collection.

GeoNearAs(Type, GeoNearArgs)

Runs a GeoNear command on this collection.

GeoNearAs(Type, IMongoQuery, double, double, int)

Runs a GeoNear command on this collection.

GeoNearAs(Type, IMongoQuery, double, double, int, IMongoGeoNearOptions)

Runs a GeoNear command on this collection.

GeoNearAs<TDocument>(GeoNearArgs)

Runs a GeoNear command on this collection.

GeoNearAs<TDocument>(IMongoQuery, double, double, int)

Runs a GeoNear command on this collection.

GeoNearAs<TDocument>(IMongoQuery, double, double, int, IMongoGeoNearOptions)

Runs a GeoNear command on this collection.

GetIndexes()

Gets the indexes for this collection.

GetStats()

Gets the stats for this collection.

GetStats(GetStatsArgs)

Gets the stats for this collection.

Group(GroupArgs)

Runs the group command on this collection.

Group(IMongoQuery, BsonJavaScript, BsonDocument, BsonJavaScript, BsonJavaScript)

Runs the group command on this collection.

Group(IMongoQuery, IMongoGroupBy, BsonDocument, BsonJavaScript, BsonJavaScript)

Runs the group command on this collection.

Group(IMongoQuery, string, BsonDocument, BsonJavaScript, BsonJavaScript)

Runs the group command on this collection.

IndexExists(IMongoIndexKeys)

Tests whether an index exists.

IndexExists(params string[])

Tests whether an index exists.

IndexExistsByName(string)

Tests whether an index exists.

InitializeOrderedBulkOperationAs<TDocument>()

Creates a fluent builder for an ordered bulk operation.

InitializeUnorderedBulkOperationAs<TDocument>()

Creates a fluent builder for an unordered bulk operation.

Insert(Type, object)

Inserts a document into this collection (see also InsertBatch to insert multiple documents at once).

Insert(Type, object, MongoInsertOptions)

Inserts a document into this collection (see also InsertBatch to insert multiple documents at once).

Insert(Type, object, WriteConcern)

Inserts a document into this collection (see also InsertBatch to insert multiple documents at once).

InsertBatch(Type, IEnumerable)

Inserts multiple documents at once into this collection (see also Insert to insert a single document).

InsertBatch(Type, IEnumerable, MongoInsertOptions)

Inserts multiple documents at once into this collection (see also Insert to insert a single document).

InsertBatch(Type, IEnumerable, WriteConcern)

Inserts multiple documents at once into this collection (see also Insert to insert a single document).

InsertBatch<TNominalType>(IEnumerable<TNominalType>)

Inserts multiple documents at once into this collection (see also Insert to insert a single document).

InsertBatch<TNominalType>(IEnumerable<TNominalType>, MongoInsertOptions)

Inserts multiple documents at once into this collection (see also Insert to insert a single document).

InsertBatch<TNominalType>(IEnumerable<TNominalType>, WriteConcern)

Inserts multiple documents at once into this collection (see also Insert to insert a single document).

Insert<TNominalType>(TNominalType)

Inserts a document into this collection (see also InsertBatch to insert multiple documents at once).

Insert<TNominalType>(TNominalType, MongoInsertOptions)

Inserts a document into this collection (see also InsertBatch to insert multiple documents at once).

Insert<TNominalType>(TNominalType, WriteConcern)

Inserts a document into this collection (see also InsertBatch to insert multiple documents at once).

IsCapped()

Tests whether this collection is capped.

MapReduce(MapReduceArgs)

Runs a map-reduce command on this collection.

ParallelScanAs(Type, ParallelScanArgs)

Scans an entire collection in parallel using multiple cursors.

ParallelScanAs<TDocument>(ParallelScanArgs<TDocument>)

Scans an entire collection in parallel using multiple cursors.

ReIndex()

Runs the ReIndex command on this collection.

Remove(IMongoQuery)

Removes documents from this collection that match a query.

Remove(IMongoQuery, RemoveFlags)

Removes documents from this collection that match a query.

Remove(IMongoQuery, RemoveFlags, WriteConcern)

Removes documents from this collection that match a query.

Remove(IMongoQuery, WriteConcern)

Removes documents from this collection that match a query.

Remove(RemoveArgs)

Removes documents from this collection that match a query.

RemoveAll()

Removes all documents from this collection (see also Drop()).

RemoveAll(WriteConcern)

Removes all documents from this collection (see also Drop()).

Save(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.

Save(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.

Save(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.

Save<TNominalType>(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.

Save<TNominalType>(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.

Save<TNominalType>(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.

ToString()

Gets a canonical string representation for this database.

Update(IMongoQuery, IMongoUpdate)

Updates one matching document in this collection.

Update(IMongoQuery, IMongoUpdate, MongoUpdateOptions)

Updates one or more matching documents in this collection (for multiple updates use UpdateFlags.Multi).

Update(IMongoQuery, IMongoUpdate, UpdateFlags)

Updates one or more matching documents in this collection (for multiple updates use UpdateFlags.Multi).

Update(IMongoQuery, IMongoUpdate, UpdateFlags, WriteConcern)

Updates one or more matching documents in this collection (for multiple updates use UpdateFlags.Multi).

Update(IMongoQuery, IMongoUpdate, WriteConcern)

Updates one matching document in this collection.

Validate()

Validates the integrity of this collection.

Validate(ValidateCollectionArgs)

Validates the integrity of this collection.