AsyncLinqExtensions.

MergeMap<TSource, TCollection, TResult>(IAsyncEnumerable<TSource>, Func<TSource, int, IAsyncEnumerable<TCollection>>, Func<TSource, TCollection, TResult>) Method

Summary

Projects each element of a sequence to an System.Collections.Generic.IAsyncEnumerable`1, flattens the resulting sequences into one sequence, and invokes a result selector function on each element therein. The index of each source element is used in the intermediate projected form of that element.

Syntax

public static IAsyncEnumerable<TResult> MergeMap<TSource, TCollection, TResult>(this IAsyncEnumerable<TSource> source, Func<TSource, int, IAsyncEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)

Type Parameters

Name Description
TSource The type of the elements of source.
TCollection The type of the intermediate elements collected by collectionSelector.
TResult The type of the elements of the resulting sequence.

Parameters

Name Type Description
source IAsyncEnumerable<TSource> A sequence of values to project.
collectionSelector Func<TSource, int, IAsyncEnumerable<TCollection>> A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
resultSelector Func<TSource, TCollection, TResult> A transform function to apply to each element of the intermediate sequence.

Return Value

Type Description
IAsyncEnumerable<TResult> An System.Collections.Generic.IAsyncEnumerable`1 whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of source and then mapping each of those sequence elements and their corresponding source element to a result element.