AsyncEnumerable.ToLookupAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
ToLookupAsync<TSource,TKey,TElement>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>, CancellationToken)
- Source:
- ToLookupAsync.cs
Creates a ILookup<TKey,TElement> from an IAsyncEnumerable<T> according to a specified key selector function and element selector functions.
public static System.Threading.Tasks.ValueTask<System.Linq.ILookup<TKey,TElement>> ToLookupAsync<TSource,TKey,TElement>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,TKey> keySelector, Func<TSource,TElement> elementSelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer = default, System.Threading.CancellationToken cancellationToken = default);
static member ToLookupAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, 'Key> * Func<'Source, 'Element> * System.Collections.Generic.IEqualityComparer<'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Linq.ILookup<'Key, 'Element>>
<Extension()>
Public Function ToLookupAsync(Of TSource, TKey, TElement) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, TKey), elementSelector As Func(Of TSource, TElement), Optional comparer As IEqualityComparer(Of TKey) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of ILookup(Of TKey, TElement))
Type Parameters
- TSource
The type of the elements of source
.
- TKey
The type of the key returned by keySelector
.
- TElement
The type of the value returned by elementSelector
.
Parameters
- source
- IAsyncEnumerable<TSource>
The IAsyncEnumerable<T> to create a ILookup<TKey,TElement> from.
- keySelector
- Func<TSource,TKey>
A function to extract a key from each element.
- elementSelector
- Func<TSource,TElement>
A transform function to produce a result element value from each element.
- comparer
- IEqualityComparer<TKey>
An IEqualityComparer<T> to compare keys.
- cancellationToken
- CancellationToken
The CancellationToken to monitor for cancellation requests. The default is None.
Returns
A ILookup<TKey,TElement> that contains keys and values.
Exceptions
keySelector
is null
.
Applies to
ToLookupAsync<TSource,TKey,TElement>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<TKey>>, Func<TSource, CancellationToken,ValueTask<TElement>>, IEqualityComparer<TKey>, CancellationToken)
- Source:
- ToLookupAsync.cs
Creates a ILookup<TKey,TElement> from an IAsyncEnumerable<T> according to a specified key selector function and element selector functions.
public static System.Threading.Tasks.ValueTask<System.Linq.ILookup<TKey,TElement>> ToLookupAsync<TSource,TKey,TElement>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TKey>> keySelector, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TElement>> elementSelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer = default, System.Threading.CancellationToken cancellationToken = default);
static member ToLookupAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'Key>> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'Element>> * System.Collections.Generic.IEqualityComparer<'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Linq.ILookup<'Key, 'Element>>
<Extension()>
Public Function ToLookupAsync(Of TSource, TKey, TElement) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, CancellationToken, ValueTask(Of TKey)), elementSelector As Func(Of TSource, CancellationToken, ValueTask(Of TElement)), Optional comparer As IEqualityComparer(Of TKey) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of ILookup(Of TKey, TElement))
Type Parameters
- TSource
The type of the elements of source
.
- TKey
The type of the key returned by keySelector
.
- TElement
The type of the value returned by elementSelector
.
Parameters
- source
- IAsyncEnumerable<TSource>
The IAsyncEnumerable<T> to create a ILookup<TKey,TElement> from.
- keySelector
- Func<TSource,CancellationToken,ValueTask<TKey>>
A function to extract a key from each element.
- elementSelector
- Func<TSource,CancellationToken,ValueTask<TElement>>
A transform function to produce a result element value from each element.
- comparer
- IEqualityComparer<TKey>
An IEqualityComparer<T> to compare keys.
- cancellationToken
- CancellationToken
The CancellationToken to monitor for cancellation requests. The default is None.
Returns
A ILookup<TKey,TElement> that contains keys and values.
Exceptions
keySelector
is null
.
Applies to
ToLookupAsync<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<TKey>>, IEqualityComparer<TKey>, CancellationToken)
- Source:
- ToLookupAsync.cs
Creates a ILookup<TKey,TElement> from an IAsyncEnumerable<T> according to a specified key selector function.
public static System.Threading.Tasks.ValueTask<System.Linq.ILookup<TKey,TSource>> ToLookupAsync<TSource,TKey>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TKey>> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer = default, System.Threading.CancellationToken cancellationToken = default);
static member ToLookupAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'Key>> * System.Collections.Generic.IEqualityComparer<'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Linq.ILookup<'Key, 'Source>>
<Extension()>
Public Function ToLookupAsync(Of TSource, TKey) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, CancellationToken, ValueTask(Of TKey)), Optional comparer As IEqualityComparer(Of TKey) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of ILookup(Of TKey, TSource))
Type Parameters
- TSource
The type of the elements of source
.
- TKey
The type of the key returned by keySelector
.
Parameters
- source
- IAsyncEnumerable<TSource>
The IAsyncEnumerable<T> to create a ILookup<TKey,TElement> from.
- keySelector
- Func<TSource,CancellationToken,ValueTask<TKey>>
A function to extract a key from each element.
- comparer
- IEqualityComparer<TKey>
An IEqualityComparer<T> to compare keys.
- cancellationToken
- CancellationToken
The CancellationToken to monitor for cancellation requests. The default is None.
Returns
A ILookup<TKey,TElement> that contains keys and values.
Exceptions
keySelector
is null
.
Applies to
ToLookupAsync<TSource,TKey>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>, CancellationToken)
- Source:
- ToLookupAsync.cs
Creates a ILookup<TKey,TElement> from an IAsyncEnumerable<T> according to a specified key selector function.
public static System.Threading.Tasks.ValueTask<System.Linq.ILookup<TKey,TSource>> ToLookupAsync<TSource,TKey>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,TKey> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer = default, System.Threading.CancellationToken cancellationToken = default);
static member ToLookupAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, 'Key> * System.Collections.Generic.IEqualityComparer<'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Linq.ILookup<'Key, 'Source>>
<Extension()>
Public Function ToLookupAsync(Of TSource, TKey) (source As IAsyncEnumerable(Of TSource), keySelector As Func(Of TSource, TKey), Optional comparer As IEqualityComparer(Of TKey) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of ILookup(Of TKey, TSource))
Type Parameters
- TSource
The type of the elements of source
.
- TKey
The type of the key returned by keySelector
.
Parameters
- source
- IAsyncEnumerable<TSource>
The IAsyncEnumerable<T> to create a ILookup<TKey,TElement> from.
- keySelector
- Func<TSource,TKey>
A function to extract a key from each element.
- comparer
- IEqualityComparer<TKey>
An IEqualityComparer<T> to compare keys.
- cancellationToken
- CancellationToken
The CancellationToken to monitor for cancellation requests. The default is None.
Returns
A ILookup<TKey,TElement> that contains keys and values.
Exceptions
keySelector
is null
.