Table of Contents

Method Lookup

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

Lookup<TResult>(IAggregateFluent<TResult>, string, FieldDefinition<TResult>, FieldDefinition<BsonDocument>, FieldDefinition<BsonDocument>)

Appends a lookup stage to the pipeline.

public static IAggregateFluent<BsonDocument> Lookup<TResult>(this IAggregateFluent<TResult> aggregate, string foreignCollectionName, FieldDefinition<TResult> localField, FieldDefinition<BsonDocument> foreignField, FieldDefinition<BsonDocument> @as)

Parameters

aggregate IAggregateFluent<TResult>

The aggregate.

foreignCollectionName string

Name of the foreign collection.

localField FieldDefinition<TResult>

The local field.

foreignField FieldDefinition<BsonDocument>

The foreign field.

as FieldDefinition<BsonDocument>

The field in the result to place the foreign matches.

Returns

IAggregateFluent<BsonDocument>

The fluent aggregate interface.

Type Parameters

TResult

The type of the result.

Lookup<TResult, TForeignDocument, TNewResult>(IAggregateFluent<TResult>, IMongoCollection<TForeignDocument>, Expression<Func<TResult, object>>, Expression<Func<TForeignDocument, object>>, Expression<Func<TNewResult, object>>, AggregateLookupOptions<TForeignDocument, TNewResult>)

Appends a lookup stage to the pipeline.

public static IAggregateFluent<TNewResult> Lookup<TResult, TForeignDocument, TNewResult>(this IAggregateFluent<TResult> aggregate, IMongoCollection<TForeignDocument> foreignCollection, Expression<Func<TResult, object>> localField, Expression<Func<TForeignDocument, object>> foreignField, Expression<Func<TNewResult, object>> @as, AggregateLookupOptions<TForeignDocument, TNewResult> options = null)

Parameters

aggregate IAggregateFluent<TResult>

The aggregate.

foreignCollection IMongoCollection<TForeignDocument>

The foreign collection.

localField Expression<Func<TResult, object>>

The local field.

foreignField Expression<Func<TForeignDocument, object>>

The foreign field.

as Expression<Func<TNewResult, object>>

The field in the result to place the foreign matches.

options AggregateLookupOptions<TForeignDocument, TNewResult>

The options.

Returns

IAggregateFluent<TNewResult>

The fluent aggregate interface.

Type Parameters

TResult

The type of the result.

TForeignDocument

The type of the foreign collection.

TNewResult

The type of the new result.

Lookup<TResult>(IAggregateFluent<TResult>, IMongoCollection<BsonDocument>, BsonDocument, PipelineDefinition<BsonDocument, BsonDocument>, FieldDefinition<BsonDocument, IEnumerable<BsonDocument>>)

Appends a lookup stage to the pipeline.

public static IAggregateFluent<BsonDocument> Lookup<TResult>(this IAggregateFluent<TResult> aggregate, IMongoCollection<BsonDocument> foreignCollection, BsonDocument let, PipelineDefinition<BsonDocument, BsonDocument> lookupPipeline, FieldDefinition<BsonDocument, IEnumerable<BsonDocument>> @as)

Parameters

aggregate IAggregateFluent<TResult>

The aggregate.

foreignCollection IMongoCollection<BsonDocument>

The foreign collection.

let BsonDocument

The "let" definition.

lookupPipeline PipelineDefinition<BsonDocument, BsonDocument>

The lookup pipeline.

as FieldDefinition<BsonDocument, IEnumerable<BsonDocument>>

The as field in the result in which to place the results of the lookup pipeline.

Returns

IAggregateFluent<BsonDocument>

The fluent aggregate interface.

Type Parameters

TResult

The type of the result.

Lookup<TResult, TForeignDocument, TAsElement, TAs, TNewResult>(IAggregateFluent<TResult>, IMongoCollection<TForeignDocument>, BsonDocument, PipelineDefinition<TForeignDocument, TAsElement>, Expression<Func<TNewResult, TAs>>, AggregateLookupOptions<TForeignDocument, TNewResult>)

Appends a lookup stage to the pipeline.

public static IAggregateFluent<TNewResult> Lookup<TResult, TForeignDocument, TAsElement, TAs, TNewResult>(this IAggregateFluent<TResult> aggregate, IMongoCollection<TForeignDocument> foreignCollection, BsonDocument let, PipelineDefinition<TForeignDocument, TAsElement> lookupPipeline, Expression<Func<TNewResult, TAs>> @as, AggregateLookupOptions<TForeignDocument, TNewResult> options = null) where TAs : IEnumerable<TAsElement>

Parameters

aggregate IAggregateFluent<TResult>

The aggregate.

foreignCollection IMongoCollection<TForeignDocument>

The foreign collection.

let BsonDocument

The "let" definition.

lookupPipeline PipelineDefinition<TForeignDocument, TAsElement>

The lookup pipeline.

as Expression<Func<TNewResult, TAs>>

The as field in TNewResult in which to place the results of the lookup pipeline.

options AggregateLookupOptions<TForeignDocument, TNewResult>

The options.

Returns

IAggregateFluent<TNewResult>

The fluent aggregate interface.

Type Parameters

TResult

The type of the result.

TForeignDocument

The type of the foreign collection documents.

TAsElement

The type of the as field elements.

TAs

The type of the as field.

TNewResult

The type of the new result.