Läs på engelska Redigera

Dela via


Queryable.AggregateBy 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

AggregateBy<TSource,TKey,TAccumulate>(IQueryable<TSource>, Expression<Func<TSource, TKey>>, Expression<Func<TKey,TAccumulate>>, Expression<Func<TAccumulate, TSource,TAccumulate>>, IEqualityComparer<TKey>)

Source:
Queryable.cs

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

C#
public static System.Linq.IQueryable<System.Collections.Generic.KeyValuePair<TKey,TAccumulate>> AggregateBy<TSource,TKey,TAccumulate>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector, System.Linq.Expressions.Expression<Func<TKey,TAccumulate>> seedSelector, System.Linq.Expressions.Expression<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
IQueryable<TSource>

An IQueryable<T> to aggregate over.

keySelector
Expression<Func<TSource,TKey>>

A function to extract the key for each element.

seedSelector
Expression<Func<TKey,TAccumulate>>

A factory for the initial accumulator value.

func
Expression<Func<TAccumulate,TSource,TAccumulate>>

An accumulator function to be invoked on each element.

keyComparer
IEqualityComparer<TKey>

An IEqualityComparer<T> to compare keys with.

Returns

IQueryable<KeyValuePair<TKey,TAccumulate>>

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

Remarks

This method is comparable to the GroupBy<TSource,TKey>(IQueryable<TSource>, Expression<Func<TSource,TKey>>) methods where each grouping is being aggregated into a single value as opposed to allocating a collection for each group.

Applies to

.NET 10 och .NET 9
Produkt Versioner
.NET 9, 10

AggregateBy<TSource,TKey,TAccumulate>(IQueryable<TSource>, Expression<Func<TSource, TKey>>, TAccumulate, Expression<Func<TAccumulate,TSource,TAccumulate>>, IEqualityComparer<TKey>)

Source:
Queryable.cs

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

C#
public static System.Linq.IQueryable<System.Collections.Generic.KeyValuePair<TKey,TAccumulate>> AggregateBy<TSource,TKey,TAccumulate>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector, TAccumulate seed, System.Linq.Expressions.Expression<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
IQueryable<TSource>

An IQueryable<T> to aggregate over.

keySelector
Expression<Func<TSource,TKey>>

A function to extract the key for each element.

seed
TAccumulate

The initial accumulator value.

func
Expression<Func<TAccumulate,TSource,TAccumulate>>

An accumulator function to be invoked on each element.

keyComparer
IEqualityComparer<TKey>

An IEqualityComparer<T> to compare keys with.

Returns

IQueryable<KeyValuePair<TKey,TAccumulate>>

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

Remarks

This method is comparable to the GroupBy<TSource,TKey>(IQueryable<TSource>, Expression<Func<TSource,TKey>>) methods where each grouping is being aggregated into a single value as opposed to allocating a collection for each group.

Applies to

.NET 10 och .NET 9
Produkt Versioner
.NET 9, 10