Skip to content

Queryable.{Aggregate,Count}By accept optional argument values and cannot appear in an Expression tree #113881

@jcracknell

Description

@jcracknell

public static IQueryable<KeyValuePair<TKey, TAccumulate>> AggregateBy<TSource, TKey, TAccumulate>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> func, IEqualityComparer<TKey>? keyComparer = null) where TKey : notnull

Methods having optional (default) argument values cannot appear in an expression tree, where these should presumably be usable. As a (vacuous) example:

dbContext.Owner.SelectMany(o => dbContext.Cats.CountBy(c => c.Age))

will not compile.

dotnet/efcore#33177
dotnet/efcore#32741

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions