Method SelectMany
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
sourceIMongoQueryable<TSource>A sequence of values to project.
selectorExpression<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
TSourceThe type of the elements of
source.TResultThe 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
sourceIMongoQueryable<TSource>A sequence of values to project.
collectionSelectorExpression<Func<TSource, IEnumerable<TCollection>>>A projection function to apply to each element of the input sequence.
resultSelectorExpression<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
collectionSelectoron each element ofsourceand then mapping each of those sequence elements and their correspondingsourceelement to a result element.
Type Parameters
TSourceThe type of the elements of
source.TCollectionThe type of the intermediate elements collected by the function represented by
collectionSelector.TResultThe type of the elements of the resulting sequence.