Method CountAsync
CountAsync(FilterDefinition<TDocument>, CountOptions, CancellationToken)
Counts the number of documents in the collection.
[Obsolete("Use CountDocumentsAsync or EstimatedDocumentCountAsync instead.")]
Task<long> CountAsync(FilterDefinition<TDocument> filter, CountOptions options = null, CancellationToken cancellationToken = default)
Parameters
filter
FilterDefinition<TDocument>The filter.
options
CountOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
CountAsync(IClientSessionHandle, FilterDefinition<TDocument>, CountOptions, CancellationToken)
Counts the number of documents in the collection.
[Obsolete("Use CountDocumentsAsync or EstimatedDocumentCountAsync instead.")]
Task<long> CountAsync(IClientSessionHandle session, FilterDefinition<TDocument> filter, CountOptions options = null, CancellationToken cancellationToken = default)
Parameters
session
IClientSessionHandleThe session.
filter
FilterDefinition<TDocument>The filter.
options
CountOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.