AsyncEnumerable.AggregateBy Method

Definition

Overloads

AggregateBy<TSource,TKey,TAccumulate>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, Func<TKey,TAccumulate>, Func<TAccumulate, TSource,TAccumulate>, IEqualityComparer<TKey>)

Source:
AggregateBy.cs

Applies an accumulator function over a sequence, grouping results by key.

C#
public static System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<TKey,TAccumulate>> AggregateBy<TSource,TKey,TAccumulate>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,TKey> keySelector, Func<TKey,TAccumulate> seedSelector, Func<TAccumulate,TSource,TAccumulate> func, System.Collections.Generic.IEqualityComparer<TKey>? keyComparer = default);

Type Parameters

TSource

The type of the elements of source.

TKey

The type of the key returned by keySelector.

TAccumulate

The type of the accumulator value.

Parameters

source
IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> to aggregate over.

keySelector
Func<TSource,TKey>

A function to extract the key for each element.

seedSelector
Func<TKey,TAccumulate>

A factory for the initial accumulator value.

func
Func<TAccumulate,TSource,TAccumulate>

An accumulator function to be invoked on each element.

keyComparer
IEqualityComparer<TKey>

An IEqualityComparer<T> to compare keys with.

Returns

IAsyncEnumerable<KeyValuePair<TKey,TAccumulate>>

An enumerable containing the aggregates corresponding to each key deriving from source.

Exceptions

func is null.

Remarks

This method is comparable to the GroupBy methods where each grouping is being aggregated into a single value as opposed to allocating a collection for each group.

Applies to

.NET 10 and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

AggregateBy<TSource,TKey,TAccumulate>(IAsyncEnumerable<TSource>, Func<TSource,TKey>, TAccumulate, Func<TAccumulate,TSource,TAccumulate>, IEqualityComparer<TKey>)

Source:
AggregateBy.cs

Applies an accumulator function over a sequence, grouping results by key.

C#
public static System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<TKey,TAccumulate>> AggregateBy<TSource,TKey,TAccumulate>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,TKey> keySelector, TAccumulate seed, Func<TAccumulate,TSource,TAccumulate> func, System.Collections.Generic.IEqualityComparer<TKey>? keyComparer = default);

Type Parameters

TSource

The type of the elements of source.

TKey

The type of the key returned by keySelector.

TAccumulate

The type of the accumulator value.

Parameters

source
IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> to aggregate over.

keySelector
Func<TSource,TKey>

A function to extract the key for each element.

seed
TAccumulate

The initial accumulator value.

func
Func<TAccumulate,TSource,TAccumulate>

An accumulator function to be invoked on each element.

keyComparer
IEqualityComparer<TKey>

An IEqualityComparer<T> to compare keys with.

Returns

IAsyncEnumerable<KeyValuePair<TKey,TAccumulate>>

An enumerable containing the aggregates corresponding to each key deriving from source.

Exceptions

func is null.

Remarks

This method is comparable to the GroupBy methods where each grouping is being aggregated into a single value as opposed to allocating a collection for each group.

Applies to

.NET 10 and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

AggregateBy<TSource,TKey,TAccumulate>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<TKey>>, Func<TKey,CancellationToken, ValueTask<TAccumulate>>, Func<TAccumulate,TSource,CancellationToken, ValueTask<TAccumulate>>, IEqualityComparer<TKey>)

Source:
AggregateBy.cs

Applies an accumulator function over a sequence, grouping results by key.

C#
public static System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<TKey,TAccumulate>> AggregateBy<TSource,TKey,TAccumulate>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TKey>> keySelector, Func<TKey,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TAccumulate>> seedSelector, Func<TAccumulate,TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TAccumulate>> func, System.Collections.Generic.IEqualityComparer<TKey>? keyComparer = default);

Type Parameters

TSource

The type of the elements of source.

TKey

The type of the key returned by keySelector.

TAccumulate

The type of the accumulator value.

Parameters

source
IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> to aggregate over.

keySelector
Func<TSource,CancellationToken,ValueTask<TKey>>

A function to extract the key for each element.

seedSelector
Func<TKey,CancellationToken,ValueTask<TAccumulate>>

A factory for the initial accumulator value.

func
Func<TAccumulate,TSource,CancellationToken,ValueTask<TAccumulate>>

An accumulator function to be invoked on each element.

keyComparer
IEqualityComparer<TKey>

An IEqualityComparer<T> to compare keys with.

Returns

IAsyncEnumerable<KeyValuePair<TKey,TAccumulate>>

An enumerable containing the aggregates corresponding to each key deriving from source.

Exceptions

func is null.

Remarks

This method is comparable to the GroupBy methods where each grouping is being aggregated into a single value as opposed to allocating a collection for each group.

Applies to

.NET 10 and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

AggregateBy<TSource,TKey,TAccumulate>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<TKey>>, TAccumulate, Func<TAccumulate,TSource,CancellationToken,ValueTask<TAccumulate>>, IEqualityComparer<TKey>)

Source:
AggregateBy.cs

Applies an accumulator function over a sequence, grouping results by key.

C#
public static System.Collections.Generic.IAsyncEnumerable<System.Collections.Generic.KeyValuePair<TKey,TAccumulate>> AggregateBy<TSource,TKey,TAccumulate>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TKey>> keySelector, TAccumulate seed, Func<TAccumulate,TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TAccumulate>> func, System.Collections.Generic.IEqualityComparer<TKey>? keyComparer = default);

Type Parameters

TSource

The type of the elements of source.

TKey

The type of the key returned by keySelector.

TAccumulate

The type of the accumulator value.

Parameters

source
IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> to aggregate over.

keySelector
Func<TSource,CancellationToken,ValueTask<TKey>>

A function to extract the key for each element.

seed
TAccumulate

The initial accumulator value.

func
Func<TAccumulate,TSource,CancellationToken,ValueTask<TAccumulate>>

An accumulator function to be invoked on each element.

keyComparer
IEqualityComparer<TKey>

An IEqualityComparer<T> to compare keys with.

Returns

IAsyncEnumerable<KeyValuePair<TKey,TAccumulate>>

An enumerable containing the aggregates corresponding to each key deriving from source.

Exceptions

func is null.

Remarks

This method is comparable to the GroupBy methods where each grouping is being aggregated into a single value as opposed to allocating a collection for each group.

Applies to

.NET 10 and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)