Skip to content

Query: Include annotation is not ignored for group by aggregate causing client eval #12173

Closed
@cdarrigo

Description

@cdarrigo

Running a simple group by expression to compute a sum of a value is failing to translate and as a result, running the group by locally.

Query:

  var summedCharges = await dataContext.Charges
                .Include(i => i.BillingItem)
                .Where(i => !i.Deleted &&
                            i.UserId == userId &&
                            i.SchoolId == schoolId &&
                            i.BillingItem.SchoolYearId == schoolYearId &&
                            i.IncludeInTrp &&
                            i.BillingItem.TypeCode != trpBillingItemTypeCode

                )
                .GroupBy(i => i.UserId)
                .Select(g => g.Sum(i => i.Amount))
                .OrderBy(i=>i.Value)
                .FirstOrDefaultAsync();

Warning Messages:

[12:53:20 WRN] The LINQ expression 'GroupBy([i].UserId, _Include(queryContext, [i], new [] {[i.BillingItem]}, (queryContext, entity, included) => { ... }))' could not be translated and will be evaluated locally.
[12:53:20 WRN] The LINQ expression 'Sum()' could not be translated and will be evaluated locally.
[12:53:20 WRN] The LINQ expression 'orderby Convert({from ChargeEntity i in [g] select [i].Amount => Sum()}, Decimal) asc' could not be translated and will be evaluated locally.
[12:53:20 WRN] The LINQ expression 'Sum()' could not be translated and will be evaluated locally.
[12:53:20 WRN] The LINQ expression 'Sum()' could not be translated and will be evaluated locally.
[12:53:20 WRN] The LINQ expression 'Sum()' could not be translated and will be evaluated locally.
[12:53:20 WRN] The LINQ expression 'FirstOrDefault()' could not be translated and will be evaluated locally.

Further technical details

EF Core version: 2.1.0-rc1-final
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Win 10
IDE: (e.g. Visual Studio 2017 15.4)

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions