Table of Contents

Class CountOperation

Namespace
MongoDB.Driver.Core.Operations
Assembly
MongoDB.Driver.Core.dll

Represents a count operation.

public class CountOperation : IReadOperation<long>, IExecutableInRetryableReadContext<long>
Inheritance
CountOperation
Implements
Inherited Members
Extension Methods

Constructors

CountOperation(CollectionNamespace, MessageEncoderSettings)

Initializes a new instance of the CountOperation class.

public CountOperation(CollectionNamespace collectionNamespace, MessageEncoderSettings messageEncoderSettings)

Parameters

collectionNamespace CollectionNamespace

The collection namespace.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

Properties

Collation

Gets or sets the collation.

public Collation Collation { get; set; }

Property Value

Collation

The collation.

CollectionNamespace

Gets the collection namespace.

public CollectionNamespace CollectionNamespace { get; }

Property Value

CollectionNamespace

The collection namespace.

Comment

Gets or sets the comment.

public BsonValue Comment { get; set; }

Property Value

BsonValue

The comment.

Filter

Gets or sets the filter.

public BsonDocument Filter { get; set; }

Property Value

BsonDocument

The filter.

Hint

Gets or sets the index hint.

public BsonValue Hint { get; set; }

Property Value

BsonValue

The index hint.

Limit

Gets or sets a limit on the number of matching documents to count.

public long? Limit { get; set; }

Property Value

long?

A limit on the number of matching documents to count.

MaxTime

Gets or sets the maximum time the server should spend on this operation.

public TimeSpan? MaxTime { get; set; }

Property Value

TimeSpan?

The maximum time the server should spend on this operation.

MessageEncoderSettings

Gets the message encoder settings.

public MessageEncoderSettings MessageEncoderSettings { get; }

Property Value

MessageEncoderSettings

The message encoder settings.

ReadConcern

Gets or sets the read concern.

public ReadConcern ReadConcern { get; set; }

Property Value

ReadConcern

The read concern.

RetryRequested

Gets or sets a value indicating whether to retry.

public bool RetryRequested { get; set; }

Property Value

bool

Whether to retry.

Skip

Gets or sets the number of documents to skip before counting the remaining matching documents.

public long? Skip { get; set; }

Property Value

long?

The number of documents to skip before counting the remaining matching documents.

Methods

Execute(IReadBinding, CancellationToken)

Executes the operation.

public long Execute(IReadBinding binding, CancellationToken cancellationToken)

Parameters

binding IReadBinding

The binding.

cancellationToken CancellationToken

The cancellation token.

Returns

long

The result of the operation.

Execute(RetryableReadContext, CancellationToken)

Executes the first attempt.

public long Execute(RetryableReadContext context, CancellationToken cancellationToken)

Parameters

context RetryableReadContext

The context.

cancellationToken CancellationToken

The cancellation token.

Returns

long

The result.

ExecuteAsync(IReadBinding, CancellationToken)

Executes the operation.

public Task<long> ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken)

Parameters

binding IReadBinding

The binding.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<long>

A Task whose result is the result of the operation.

ExecuteAsync(RetryableReadContext, CancellationToken)

Executes the first attempt.

public Task<long> ExecuteAsync(RetryableReadContext context, CancellationToken cancellationToken)

Parameters

context RetryableReadContext

The context.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<long>

The result.