Читати англійською Редагувати

Поділитися через


AsyncEnumerable.ToLookupAsync Method

Definition

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.

C#
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);

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

ValueTask<ILookup<TKey,TElement>>

A ILookup<TKey,TElement> that contains keys and values.

Exceptions

keySelector is null.

Applies to

.NET 10 та інші версії
Продукт Версії
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

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.

C#
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);

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

ValueTask<ILookup<TKey,TElement>>

A ILookup<TKey,TElement> that contains keys and values.

Exceptions

keySelector is null.

Applies to

.NET 10 та інші версії
Продукт Версії
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

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.

C#
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);

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

ValueTask<ILookup<TKey,TSource>>

A ILookup<TKey,TElement> that contains keys and values.

Exceptions

keySelector is null.

Applies to

.NET 10 та інші версії
Продукт Версії
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

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.

C#
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);

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

ValueTask<ILookup<TKey,TSource>>

A ILookup<TKey,TElement> that contains keys and values.

Exceptions

keySelector is null.

Applies to

.NET 10 та інші версії
Продукт Версії
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)