@@ -48,6 +48,16 @@ public static async IAsyncEnumerable<TResult> SelectManyAsync<T, TResult>(this I
4848 }
4949 }
5050
51+ public static async IAsyncEnumerable < TResult > SelectManyAsync < T , TResult > ( this IAsyncEnumerable < T > source , Func < T , Task < TResult [ ] > > selector , [ EnumeratorCancellation ] CancellationToken cancellationToken = default )
52+ {
53+ await foreach ( var item in source . WithCancellation ( cancellationToken ) . ConfigureAwait ( false ) )
54+ foreach ( var result in await selector ( item ) . ConfigureAwait ( false ) )
55+ {
56+ cancellationToken . ThrowIfCancellationRequested ( ) ;
57+ yield return result ;
58+ }
59+ }
60+
5161 public static async IAsyncEnumerable < TResult > SelectManyAsync < T , TResult > ( this IEnumerable < T > source , Func < T , IAsyncEnumerable < TResult > > selector , [ EnumeratorCancellation ] CancellationToken cancellationToken = default )
5262 {
5363 cancellationToken . ThrowIfCancellationRequested ( ) ;
@@ -73,6 +83,16 @@ public static async IAsyncEnumerable<TResult> SelectManyAsync<T, TCollection, TR
7383 }
7484 }
7585
86+ public static async IAsyncEnumerable < TResult > SelectManyAsync < T , TCollection , TResult > ( this IAsyncEnumerable < T > source , Func < T , Task < IEnumerable < TCollection > > > collectionSelector , Func < T , TCollection , TResult > resultSelector , [ EnumeratorCancellation ] CancellationToken cancellationToken = default )
87+ {
88+ await foreach ( var item in source . WithCancellation ( cancellationToken ) . ConfigureAwait ( false ) )
89+ foreach ( var result in await collectionSelector ( item ) . ConfigureAwait ( false ) )
90+ {
91+ cancellationToken . ThrowIfCancellationRequested ( ) ;
92+ yield return resultSelector ( item , result ) ;
93+ }
94+ }
95+
7696 public static async IAsyncEnumerable < TResult > SelectManyAsync < T , TCollection , TResult > ( this IEnumerable < T > source , Func < T , Task < IEnumerable < TCollection > > > collectionSelector , Func < T , TCollection , TResult > resultSelector , [ EnumeratorCancellation ] CancellationToken cancellationToken = default )
7797 {
7898 cancellationToken . ThrowIfCancellationRequested ( ) ;
@@ -120,6 +140,16 @@ public static async IAsyncEnumerable<TResult> SelectManyAsync<T, TCollection, TR
120140 }
121141 }
122142
143+ public static async IAsyncEnumerable < TResult > SelectManyAsync < T , TCollection , TResult > ( this IAsyncEnumerable < T > source , Func < T , Task < IEnumerable < TCollection > > > collectionSelector , Func < T , TCollection , Task < TResult > > resultSelector , [ EnumeratorCancellation ] CancellationToken cancellationToken = default )
144+ {
145+ await foreach ( var item in source . WithCancellation ( cancellationToken ) . ConfigureAwait ( false ) )
146+ foreach ( var result in await collectionSelector ( item ) . ConfigureAwait ( false ) )
147+ {
148+ cancellationToken . ThrowIfCancellationRequested ( ) ;
149+ yield return await resultSelector ( item , result ) . ConfigureAwait ( false ) ;
150+ }
151+ }
152+
123153 public static async IAsyncEnumerable < TResult > SelectManyAsync < T , TCollection , TResult > ( this IEnumerable < T > source , Func < T , Task < IEnumerable < TCollection > > > collectionSelector , Func < T , TCollection , Task < TResult > > resultSelector , [ EnumeratorCancellation ] CancellationToken cancellationToken = default )
124154 {
125155 cancellationToken . ThrowIfCancellationRequested ( ) ;
0 commit comments