按语句分组不能转换为SQL

问题描述

EF Core 3.1中是否有办法使类似下面的语句按组工作?

 .GroupBy(x => x.Id,(id,item) =>
          new 
          {
              Id = id,LastDate = item.Max(z => z.Date)
          })

Id为uniqueidentifier,Date为datetime2(7)

当前无法将其转换为sql错误

The LINQ expression 'DbSet<Delivery>
    .GroupBy(
        source: p => p.Id,keySelector: p => p,elementSelector: (x,y) => new { 
            Id = x,LastDate = y
                .Max(z => z.Date)
         })' Could not be translated. Either rewrite the query in a form that can be translated,or switch to client evaluation explicitly by inserting a call to either AsEnumerable(),AsAsyncEnumerable(),ToList(),or ToListAsync().

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)