Table of Contents

Method Count

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

Count(FilterDefinition<TDocument>, CountOptions, CancellationToken)

Counts the number of documents in the collection.

[Obsolete("Use CountDocuments or EstimatedDocumentCount instead.")]
public virtual long Count(FilterDefinition<TDocument> filter, CountOptions options = null, CancellationToken cancellationToken = default)

Parameters

filter FilterDefinition<TDocument>

The filter.

options CountOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

long

The number of documents in the collection.

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

Counts the number of documents in the collection.

[Obsolete("Use CountDocuments or EstimatedDocumentCount instead.")]
public virtual long Count(IClientSessionHandle session, FilterDefinition<TDocument> filter, CountOptions options = null, CancellationToken cancellationToken = default)

Parameters

session IClientSessionHandle

The session.

filter FilterDefinition<TDocument>

The filter.

options CountOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

long

The number of documents in the collection.