Table of Contents

Method SelectMany

Namespace
MongoDB.Driver.Linq
Assembly
MongoDB.Driver.dll

SelectMany<TSource, TResult>(IMongoQueryable<TSource>, Expression<Func<TSource, IEnumerable<TResult>>>)

Projects each element of a sequence to an IEnumerable<T> and combines the resulting sequences into one sequence.

public static IMongoQueryable<TResult> SelectMany<TSource, TResult>(this IMongoQueryable<TSource> source, Expression<Func<TSource, IEnumerable<TResult>>> selector)

Parameters

source IMongoQueryable<TSource>

A sequence of values to project.

selector Expression<Func<TSource, IEnumerable<TResult>>>

A projection function to apply to each element.

Returns

IMongoQueryable<TResult>

An IMongoQueryable<T> whose elements are the result of invoking a one-to-many projection function on each element of the input sequence.

Type Parameters

TSource

The type of the elements of source.

TResult

The type of the elements of the sequence returned by the function represented by selector.

SelectMany<TSource, TCollection, TResult>(IMongoQueryable<TSource>, Expression<Func<TSource, IEnumerable<TCollection>>>, Expression<Func<TSource, TCollection, TResult>>)

Projects each element of a sequence to an IEnumerable<T> and invokes a result selector function on each element therein. The resulting values from each intermediate sequence are combined into a single, one-dimensional sequence and returned.

public static IMongoQueryable<TResult> SelectMany<TSource, TCollection, TResult>(this IMongoQueryable<TSource> source, Expression<Func<TSource, IEnumerable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector)

Parameters

source IMongoQueryable<TSource>

A sequence of values to project.

collectionSelector Expression<Func<TSource, IEnumerable<TCollection>>>

A projection function to apply to each element of the input sequence.

resultSelector Expression<Func<TSource, TCollection, TResult>>

A projection function to apply to each element of each intermediate sequence.

Returns

IMongoQueryable<TResult>

An IMongoQueryable<T> whose elements are the result of invoking the one-to-many projection function collectionSelector on each element of source and then mapping each of those sequence elements and their corresponding source element to a result element.

Type Parameters

TSource

The type of the elements of source.

TCollection

The type of the intermediate elements collected by the function represented by collectionSelector.

TResult

The type of the elements of the resulting sequence.