Click or drag to resize

MongoCollectionBase<TDocument>.Count Method (IClientSessionHandle, FilterDefinition<TDocument>, CountOptions, CancellationToken)

Note: This API is now obsolete.

Counts the number of documents in the collection.

Namespace:  MongoDB.Driver
Assembly:  MongoDB.Driver (in MongoDB.Driver.dll) Version: 2.11.0+cb27a82ea70620ad1acad8058809be8302ae4f2a
Syntax
[ObsoleteAttribute("Use CountDocuments or EstimatedDocumentCount instead.")]
public virtual long Count(
	IClientSessionHandle session,
	FilterDefinition<TDocument> filter,
	CountOptions options = null,
	CancellationToken cancellationToken = null
)

Parameters

session
Type: MongoDB.Driver.IClientSessionHandle
The session.
filter
Type: MongoDB.Driver.FilterDefinition<TDocument>
The filter.
options (Optional)
Type: MongoDB.Driver.CountOptions
The options.
cancellationToken (Optional)
Type: System.Threading.CancellationToken
The cancellation token.

Return Value

Type: Int64
The number of documents in the collection.

Implements

IMongoCollection<TDocument>.Count(IClientSessionHandle, FilterDefinition<TDocument>, CountOptions, CancellationToken)
See Also