How to use async lambda with SelectMany?
This is an extension: public static async Task<IEnumerable<T1>> SelectManyAsync<T, T1>(this IEnumerable<T> enumeration, Func<T, Task<IEnumerable<T1>>> func) { return (await Task.WhenAll(enumeration.Select(func))).SelectMany(s => s); } That allows you to run: var result = await myEnumerable.SelectManyAsync(c => Functions.GetDataAsync(c.Id)); Explanation: you have a list of tasks, each returns Task<IEnumerable<T>>. So you need to fire them all, then await all, and … Read more