Table of Contents

Method Group

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

Group<TInput, TIntermediate, TOutput>(PipelineDefinition<TInput, TIntermediate>, ProjectionDefinition<TIntermediate, TOutput>)

Appends a $group stage to the pipeline.

public static PipelineDefinition<TInput, TOutput> Group<TInput, TIntermediate, TOutput>(this PipelineDefinition<TInput, TIntermediate> pipeline, ProjectionDefinition<TIntermediate, TOutput> group)

Parameters

pipeline PipelineDefinition<TInput, TIntermediate>

The pipeline.

group ProjectionDefinition<TIntermediate, TOutput>

The group projection.

Returns

PipelineDefinition<TInput, TOutput>

A new pipeline with an additional stage.

Type Parameters

TInput

The type of the input documents.

TIntermediate

The type of the intermediate documents.

TOutput

The type of the output documents.

Group<TInput, TIntermediate>(PipelineDefinition<TInput, TIntermediate>, ProjectionDefinition<TIntermediate, BsonDocument>)

Appends a group stage to the pipeline.

public static PipelineDefinition<TInput, BsonDocument> Group<TInput, TIntermediate>(this PipelineDefinition<TInput, TIntermediate> pipeline, ProjectionDefinition<TIntermediate, BsonDocument> group)

Parameters

pipeline PipelineDefinition<TInput, TIntermediate>

The pipeline.

group ProjectionDefinition<TIntermediate, BsonDocument>

The group projection.

Returns

PipelineDefinition<TInput, BsonDocument>

A new pipeline with an additional stage.

Type Parameters

TInput

The type of the input documents.

TIntermediate

The type of the intermediate documents.

Group<TInput, TIntermediate, TKey, TOutput>(PipelineDefinition<TInput, TIntermediate>, Expression<Func<TIntermediate, TKey>>, Expression<Func<IGrouping<TKey, TIntermediate>, TOutput>>, ExpressionTranslationOptions)

Appends a group stage to the pipeline (this method can only be used with LINQ2).

public static PipelineDefinition<TInput, TOutput> Group<TInput, TIntermediate, TKey, TOutput>(this PipelineDefinition<TInput, TIntermediate> pipeline, Expression<Func<TIntermediate, TKey>> id, Expression<Func<IGrouping<TKey, TIntermediate>, TOutput>> group, ExpressionTranslationOptions translationOptions = null)

Parameters

pipeline PipelineDefinition<TInput, TIntermediate>

The pipeline.

id Expression<Func<TIntermediate, TKey>>

The id.

group Expression<Func<IGrouping<TKey, TIntermediate>, TOutput>>

The group projection.

translationOptions ExpressionTranslationOptions

The translation options.

Returns

PipelineDefinition<TInput, TOutput>

A new pipeline with an additional stage.

Type Parameters

TInput

The type of the input documents.

TIntermediate

The type of the intermediate documents.

TKey

The type of the key.

TOutput

The type of the output documents.

Remarks

This method can only be used with LINQ2 but that can't be verified until Render is called.