3

While migrating from Entity Framework 6 to EF Core 3, I'm hitting this error:

InvalidOperationException: Processing of the LINQ expression '(<>h__TransparentIdentifier0) => <>h__TransparentIdentifier0.grp' by 'NavigationExpandingExpressionVisitor' failed.

I believe this relates to some type of client side evaluation but I'm not sure how to fix. I essentially have this query:

var query = from s in ...
            join ...
            join ...
            select new DTO {
                Latest = (from r in _context.IndicatorCsLabUtilization
                          where r.LabSpaceId == s.Id
                          group r by r.LabSpaceId into grp
                          let maxDate = grp.Max(g => g.AssessmentDate)
                          from g in grp
                          where g.AssessmentDate == maxDate
                          select new EfficiencyAssessmentDto {
                              Comments = null,
                              Percent = g.Utilization,
                              When = g.AssessmentDate
                          }).FirstOrDefault(),
                ....

That "Latest" one is the part that's causing the failure. Can somebody help me understand how to fix that now broken query?

Gargoyle
  • 9,590
  • 16
  • 80
  • 145
  • 2
    Take a look at this question: https://stackoverflow.com/questions/58138556/client-side-groupby-is-not-supported#comment102813444_58138556 and https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-3.0/breaking-changes#linq-queries-are-no-longer-evaluated-on-the-client, it's a big problem for me that stops migrating to dotnetcore 3 – Duefectu Oct 21 '19 at 07:22

0 Answers0