Table of Contents

Interface IMongoCollection<TDocument>

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

Represents a typed collection in MongoDB.

public interface IMongoCollection<TDocument>

Type Parameters

TDocument

The type of the documents stored in the collection.

Extension Methods

Remarks

This interface is not guaranteed to remain stable. Implementors should use MongoCollectionBase<TDocument>.

Properties

CollectionNamespace

Gets the namespace of the collection.

Database

Gets the database.

DocumentSerializer

Gets the document serializer.

Indexes

Gets the index manager.

SearchIndexes

Gets the search index manager.

Settings

Gets the settings.

Methods

AggregateAsync<TResult>(IClientSessionHandle, PipelineDefinition<TDocument, TResult>, AggregateOptions, CancellationToken)

Runs an aggregation pipeline.

AggregateAsync<TResult>(PipelineDefinition<TDocument, TResult>, AggregateOptions, CancellationToken)

Runs an aggregation pipeline.

AggregateToCollectionAsync<TResult>(IClientSessionHandle, PipelineDefinition<TDocument, TResult>, AggregateOptions, CancellationToken)

Runs an aggregation pipeline whose results are written to a collection.

AggregateToCollectionAsync<TResult>(PipelineDefinition<TDocument, TResult>, AggregateOptions, CancellationToken)

Runs an aggregation pipeline whose results are written to a collection.

AggregateToCollection<TResult>(IClientSessionHandle, PipelineDefinition<TDocument, TResult>, AggregateOptions, CancellationToken)

Runs an aggregation pipeline whose results are written to a collection.

AggregateToCollection<TResult>(PipelineDefinition<TDocument, TResult>, AggregateOptions, CancellationToken)

Runs an aggregation pipeline whose results are written to a collection.

Aggregate<TResult>(IClientSessionHandle, PipelineDefinition<TDocument, TResult>, AggregateOptions, CancellationToken)

Runs an aggregation pipeline.

Aggregate<TResult>(PipelineDefinition<TDocument, TResult>, AggregateOptions, CancellationToken)

Runs an aggregation pipeline.

BulkWrite(IClientSessionHandle, IEnumerable<WriteModel<TDocument>>, BulkWriteOptions, CancellationToken)

Performs multiple write operations.

BulkWrite(IEnumerable<WriteModel<TDocument>>, BulkWriteOptions, CancellationToken)

Performs multiple write operations.

BulkWriteAsync(IClientSessionHandle, IEnumerable<WriteModel<TDocument>>, BulkWriteOptions, CancellationToken)

Performs multiple write operations.

BulkWriteAsync(IEnumerable<WriteModel<TDocument>>, BulkWriteOptions, CancellationToken)

Performs multiple write operations.

Count(FilterDefinition<TDocument>, CountOptions, CancellationToken)

Counts the number of documents in the collection.

Count(IClientSessionHandle, FilterDefinition<TDocument>, CountOptions, CancellationToken)

Counts the number of documents in the collection.

CountAsync(FilterDefinition<TDocument>, CountOptions, CancellationToken)

Counts the number of documents in the collection.

CountAsync(IClientSessionHandle, FilterDefinition<TDocument>, CountOptions, CancellationToken)

Counts the number of documents in the collection.

CountDocuments(FilterDefinition<TDocument>, CountOptions, CancellationToken)

Counts the number of documents in the collection. For a fast estimate of the total documents in a collection see EstimatedDocumentCount(EstimatedDocumentCountOptions, CancellationToken).

CountDocuments(IClientSessionHandle, FilterDefinition<TDocument>, CountOptions, CancellationToken)

Counts the number of documents in the collection. For a fast estimate of the total documents in a collection see EstimatedDocumentCount(EstimatedDocumentCountOptions, CancellationToken).

CountDocumentsAsync(FilterDefinition<TDocument>, CountOptions, CancellationToken)

Counts the number of documents in the collection. For a fast estimate of the total documents in a collection see .

CountDocumentsAsync(IClientSessionHandle, FilterDefinition<TDocument>, CountOptions, CancellationToken)

Counts the number of documents in the collection. For a fast estimate of the total documents in a collection see EstimatedDocumentCountAsync(EstimatedDocumentCountOptions, CancellationToken).

DeleteMany(FilterDefinition<TDocument>, DeleteOptions, CancellationToken)

Deletes multiple documents.

DeleteMany(FilterDefinition<TDocument>, CancellationToken)

Deletes multiple documents.

DeleteMany(IClientSessionHandle, FilterDefinition<TDocument>, DeleteOptions, CancellationToken)

Deletes multiple documents.

DeleteManyAsync(FilterDefinition<TDocument>, DeleteOptions, CancellationToken)

Deletes multiple documents.

DeleteManyAsync(FilterDefinition<TDocument>, CancellationToken)

Deletes multiple documents.

DeleteManyAsync(IClientSessionHandle, FilterDefinition<TDocument>, DeleteOptions, CancellationToken)

Deletes multiple documents.

DeleteOne(FilterDefinition<TDocument>, DeleteOptions, CancellationToken)

Deletes a single document.

DeleteOne(FilterDefinition<TDocument>, CancellationToken)

Deletes a single document.

DeleteOne(IClientSessionHandle, FilterDefinition<TDocument>, DeleteOptions, CancellationToken)

Deletes a single document.

DeleteOneAsync(FilterDefinition<TDocument>, DeleteOptions, CancellationToken)

Deletes a single document.

DeleteOneAsync(FilterDefinition<TDocument>, CancellationToken)

Deletes a single document.

DeleteOneAsync(IClientSessionHandle, FilterDefinition<TDocument>, DeleteOptions, CancellationToken)

Deletes a single document.

DistinctAsync<TField>(FieldDefinition<TDocument, TField>, FilterDefinition<TDocument>, DistinctOptions, CancellationToken)

Gets the distinct values for a specified field.

DistinctAsync<TField>(IClientSessionHandle, FieldDefinition<TDocument, TField>, FilterDefinition<TDocument>, DistinctOptions, CancellationToken)

Gets the distinct values for a specified field.

Distinct<TField>(FieldDefinition<TDocument, TField>, FilterDefinition<TDocument>, DistinctOptions, CancellationToken)

Gets the distinct values for a specified field.

Distinct<TField>(IClientSessionHandle, FieldDefinition<TDocument, TField>, FilterDefinition<TDocument>, DistinctOptions, CancellationToken)

Gets the distinct values for a specified field.

EstimatedDocumentCount(EstimatedDocumentCountOptions, CancellationToken)

Returns an estimate of the number of documents in the collection.

EstimatedDocumentCountAsync(EstimatedDocumentCountOptions, CancellationToken)

Returns an estimate of the number of documents in the collection.

FindAsync<TProjection>(FilterDefinition<TDocument>, FindOptions<TDocument, TProjection>, CancellationToken)

Finds the documents matching the filter.

FindAsync<TProjection>(IClientSessionHandle, FilterDefinition<TDocument>, FindOptions<TDocument, TProjection>, CancellationToken)

Finds the documents matching the filter.

FindOneAndDeleteAsync<TProjection>(FilterDefinition<TDocument>, FindOneAndDeleteOptions<TDocument, TProjection>, CancellationToken)

Finds a single document and deletes it atomically.

FindOneAndDeleteAsync<TProjection>(IClientSessionHandle, FilterDefinition<TDocument>, FindOneAndDeleteOptions<TDocument, TProjection>, CancellationToken)

Finds a single document and deletes it atomically.

FindOneAndDelete<TProjection>(FilterDefinition<TDocument>, FindOneAndDeleteOptions<TDocument, TProjection>, CancellationToken)

Finds a single document and deletes it atomically.

FindOneAndDelete<TProjection>(IClientSessionHandle, FilterDefinition<TDocument>, FindOneAndDeleteOptions<TDocument, TProjection>, CancellationToken)

Finds a single document and deletes it atomically.

FindOneAndReplaceAsync<TProjection>(FilterDefinition<TDocument>, TDocument, FindOneAndReplaceOptions<TDocument, TProjection>, CancellationToken)

Finds a single document and replaces it atomically.

FindOneAndReplaceAsync<TProjection>(IClientSessionHandle, FilterDefinition<TDocument>, TDocument, FindOneAndReplaceOptions<TDocument, TProjection>, CancellationToken)

Finds a single document and replaces it atomically.

FindOneAndReplace<TProjection>(FilterDefinition<TDocument>, TDocument, FindOneAndReplaceOptions<TDocument, TProjection>, CancellationToken)

Finds a single document and replaces it atomically.

FindOneAndReplace<TProjection>(IClientSessionHandle, FilterDefinition<TDocument>, TDocument, FindOneAndReplaceOptions<TDocument, TProjection>, CancellationToken)

Finds a single document and replaces it atomically.

FindOneAndUpdateAsync<TProjection>(FilterDefinition<TDocument>, UpdateDefinition<TDocument>, FindOneAndUpdateOptions<TDocument, TProjection>, CancellationToken)

Finds a single document and updates it atomically.

FindOneAndUpdateAsync<TProjection>(IClientSessionHandle, FilterDefinition<TDocument>, UpdateDefinition<TDocument>, FindOneAndUpdateOptions<TDocument, TProjection>, CancellationToken)

Finds a single document and updates it atomically.

FindOneAndUpdate<TProjection>(FilterDefinition<TDocument>, UpdateDefinition<TDocument>, FindOneAndUpdateOptions<TDocument, TProjection>, CancellationToken)

Finds a single document and updates it atomically.

FindOneAndUpdate<TProjection>(IClientSessionHandle, FilterDefinition<TDocument>, UpdateDefinition<TDocument>, FindOneAndUpdateOptions<TDocument, TProjection>, CancellationToken)

Finds a single document and updates it atomically.

FindSync<TProjection>(FilterDefinition<TDocument>, FindOptions<TDocument, TProjection>, CancellationToken)

Finds the documents matching the filter.

FindSync<TProjection>(IClientSessionHandle, FilterDefinition<TDocument>, FindOptions<TDocument, TProjection>, CancellationToken)

Finds the documents matching the filter.

InsertMany(IClientSessionHandle, IEnumerable<TDocument>, InsertManyOptions, CancellationToken)

Inserts many documents.

InsertMany(IEnumerable<TDocument>, InsertManyOptions, CancellationToken)

Inserts many documents.

InsertManyAsync(IClientSessionHandle, IEnumerable<TDocument>, InsertManyOptions, CancellationToken)

Inserts many documents.

InsertManyAsync(IEnumerable<TDocument>, InsertManyOptions, CancellationToken)

Inserts many documents.

InsertOne(IClientSessionHandle, TDocument, InsertOneOptions, CancellationToken)

Inserts a single document.

InsertOne(TDocument, InsertOneOptions, CancellationToken)

Inserts a single document.

InsertOneAsync(IClientSessionHandle, TDocument, InsertOneOptions, CancellationToken)

Inserts a single document.

InsertOneAsync(TDocument, InsertOneOptions, CancellationToken)

Inserts a single document.

InsertOneAsync(TDocument, CancellationToken)

Inserts a single document.

MapReduceAsync<TResult>(BsonJavaScript, BsonJavaScript, MapReduceOptions<TDocument, TResult>, CancellationToken)

Executes a map-reduce command.

MapReduceAsync<TResult>(IClientSessionHandle, BsonJavaScript, BsonJavaScript, MapReduceOptions<TDocument, TResult>, CancellationToken)

Executes a map-reduce command.

MapReduce<TResult>(BsonJavaScript, BsonJavaScript, MapReduceOptions<TDocument, TResult>, CancellationToken)

Executes a map-reduce command.

MapReduce<TResult>(IClientSessionHandle, BsonJavaScript, BsonJavaScript, MapReduceOptions<TDocument, TResult>, CancellationToken)

Executes a map-reduce command.

OfType<TDerivedDocument>()

Returns a filtered collection that appears to contain only documents of the derived type. All operations using this filtered collection will automatically use discriminators as necessary.

ReplaceOne(FilterDefinition<TDocument>, TDocument, ReplaceOptions, CancellationToken)

Replaces a single document.

ReplaceOne(FilterDefinition<TDocument>, TDocument, UpdateOptions, CancellationToken)

Replaces a single document.

ReplaceOne(IClientSessionHandle, FilterDefinition<TDocument>, TDocument, ReplaceOptions, CancellationToken)

Replaces a single document.

ReplaceOne(IClientSessionHandle, FilterDefinition<TDocument>, TDocument, UpdateOptions, CancellationToken)

Replaces a single document.

ReplaceOneAsync(FilterDefinition<TDocument>, TDocument, ReplaceOptions, CancellationToken)

Replaces a single document.

ReplaceOneAsync(FilterDefinition<TDocument>, TDocument, UpdateOptions, CancellationToken)

Replaces a single document.

ReplaceOneAsync(IClientSessionHandle, FilterDefinition<TDocument>, TDocument, ReplaceOptions, CancellationToken)

Replaces a single document.

ReplaceOneAsync(IClientSessionHandle, FilterDefinition<TDocument>, TDocument, UpdateOptions, CancellationToken)

Replaces a single document.

UpdateMany(FilterDefinition<TDocument>, UpdateDefinition<TDocument>, UpdateOptions, CancellationToken)

Updates many documents.

UpdateMany(IClientSessionHandle, FilterDefinition<TDocument>, UpdateDefinition<TDocument>, UpdateOptions, CancellationToken)

Updates many documents.

UpdateManyAsync(FilterDefinition<TDocument>, UpdateDefinition<TDocument>, UpdateOptions, CancellationToken)

Updates many documents.

UpdateManyAsync(IClientSessionHandle, FilterDefinition<TDocument>, UpdateDefinition<TDocument>, UpdateOptions, CancellationToken)

Updates many documents.

UpdateOne(FilterDefinition<TDocument>, UpdateDefinition<TDocument>, UpdateOptions, CancellationToken)

Updates a single document.

UpdateOne(IClientSessionHandle, FilterDefinition<TDocument>, UpdateDefinition<TDocument>, UpdateOptions, CancellationToken)

Updates a single document.

UpdateOneAsync(FilterDefinition<TDocument>, UpdateDefinition<TDocument>, UpdateOptions, CancellationToken)

Updates a single document.

UpdateOneAsync(IClientSessionHandle, FilterDefinition<TDocument>, UpdateDefinition<TDocument>, UpdateOptions, CancellationToken)

Updates a single document.

WatchAsync<TResult>(IClientSessionHandle, PipelineDefinition<ChangeStreamDocument<TDocument>, TResult>, ChangeStreamOptions, CancellationToken)

Watches changes on the collection.

WatchAsync<TResult>(PipelineDefinition<ChangeStreamDocument<TDocument>, TResult>, ChangeStreamOptions, CancellationToken)

Watches changes on the collection.

Watch<TResult>(IClientSessionHandle, PipelineDefinition<ChangeStreamDocument<TDocument>, TResult>, ChangeStreamOptions, CancellationToken)

Watches changes on the collection.

Watch<TResult>(PipelineDefinition<ChangeStreamDocument<TDocument>, TResult>, ChangeStreamOptions, CancellationToken)

Watches changes on the collection.

WithReadConcern(ReadConcern)

Returns a new IMongoCollection instance with a different read concern setting.

WithReadPreference(ReadPreference)

Returns a new IMongoCollection instance with a different read preference setting.

WithWriteConcern(WriteConcern)

Returns a new IMongoCollection instance with a different write concern setting.