Table of Contents

Class AggregateOperation<TResult>

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

Represents an aggregate operation.

public class AggregateOperation<TResult> : IReadOperation<IAsyncCursor<TResult>>, IExecutableInRetryableReadContext<IAsyncCursor<TResult>>

Type Parameters

TResult

The type of the result values.

Inheritance
AggregateOperation<TResult>
Implements
Inherited Members
Extension Methods

Constructors

AggregateOperation(CollectionNamespace, IEnumerable<BsonDocument>, IBsonSerializer<TResult>, MessageEncoderSettings)

Initializes a new instance of the AggregateOperation<TResult> class.

public AggregateOperation(CollectionNamespace collectionNamespace, IEnumerable<BsonDocument> pipeline, IBsonSerializer<TResult> resultSerializer, MessageEncoderSettings messageEncoderSettings)

Parameters

collectionNamespace CollectionNamespace

The collection namespace.

pipeline IEnumerable<BsonDocument>

The pipeline.

resultSerializer IBsonSerializer<TResult>

The result value serializer.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

AggregateOperation(DatabaseNamespace, IEnumerable<BsonDocument>, IBsonSerializer<TResult>, MessageEncoderSettings)

Initializes a new instance of the AggregateOperation<TResult> class.

public AggregateOperation(DatabaseNamespace databaseNamespace, IEnumerable<BsonDocument> pipeline, IBsonSerializer<TResult> resultSerializer, MessageEncoderSettings messageEncoderSettings)

Parameters

databaseNamespace DatabaseNamespace

The database namespace.

pipeline IEnumerable<BsonDocument>

The pipeline.

resultSerializer IBsonSerializer<TResult>

The result value serializer.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

Properties

AllowDiskUse

Gets or sets a value indicating whether the server is allowed to use the disk.

public bool? AllowDiskUse { get; set; }

Property Value

bool?

A value indicating whether the server is allowed to use the disk.

BatchSize

Gets or sets the size of a batch.

public int? BatchSize { get; set; }

Property Value

int?

The size of a batch.

Collation

Gets or sets the collation.

public Collation Collation { get; set; }

Property Value

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.

DatabaseNamespace

Gets the database namespace.

public DatabaseNamespace DatabaseNamespace { get; }

Property Value

DatabaseNamespace

The database namespace.

Hint

Gets or sets the hint. This must either be a BsonString representing the index name or a BsonDocument representing the key pattern of the index.

public BsonValue Hint { get; set; }

Property Value

BsonValue

The hint.

Let

Gets or sets the "let" definition.

public BsonDocument Let { get; set; }

Property Value

BsonDocument

The "let" definition.

MaxAwaitTime

Gets or sets the maximum await time.

public TimeSpan? MaxAwaitTime { get; set; }

Property Value

TimeSpan?

The maximum await time.

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.

Pipeline

Gets the pipeline.

public IReadOnlyList<BsonDocument> Pipeline { get; }

Property Value

IReadOnlyList<BsonDocument>

The pipeline.

ReadConcern

Gets or sets the read concern.

public ReadConcern ReadConcern { get; set; }

Property Value

ReadConcern

The read concern.

ResultSerializer

Gets the result value serializer.

public IBsonSerializer<TResult> ResultSerializer { get; }

Property Value

IBsonSerializer<TResult>

The result value serializer.

RetryRequested

Gets or sets a value indicating whether to retry.

public bool RetryRequested { get; set; }

Property Value

bool

Whether to retry.

UseCursor

Gets or sets a value indicating whether the server should use a cursor to return the results.

[Obsolete("Server versions 3.6 and newer always use a cursor.")]
public bool? UseCursor { get; set; }

Property Value

bool?

A value indicating whether the server should use a cursor to return the results.

Methods

Execute(IReadBinding, CancellationToken)

Executes the operation.

public IAsyncCursor<TResult> Execute(IReadBinding binding, CancellationToken cancellationToken)

Parameters

binding IReadBinding

The binding.

cancellationToken CancellationToken

The cancellation token.

Returns

IAsyncCursor<TResult>

The result of the operation.

Execute(RetryableReadContext, CancellationToken)

Executes the first attempt.

public IAsyncCursor<TResult> Execute(RetryableReadContext context, CancellationToken cancellationToken)

Parameters

context RetryableReadContext

The context.

cancellationToken CancellationToken

The cancellation token.

Returns

IAsyncCursor<TResult>

The result.

ExecuteAsync(IReadBinding, CancellationToken)

Executes the operation.

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

Parameters

binding IReadBinding

The binding.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IAsyncCursor<TResult>>

A Task whose result is the result of the operation.

ExecuteAsync(RetryableReadContext, CancellationToken)

Executes the first attempt.

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

Parameters

context RetryableReadContext

The context.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IAsyncCursor<TResult>>

The result.

ToExplainOperation(ExplainVerbosity)

Returns an AggregateExplainOperation for this AggregateOperation.

public IReadOperation<BsonDocument> ToExplainOperation(ExplainVerbosity verbosity)

Parameters

verbosity ExplainVerbosity

The verbosity.

Returns

IReadOperation<BsonDocument>

An AggregateExplainOperation.