Asp.net Core 3.1 LINQ Expression group通过表进行选择,然后从表中进行选择,但我使用any进行了选择,但出现错误。
但是它在asp.net标准中工作正常。
码:
List<GetObj> liste = dbContext.testTable.Where(x => x.isActive == true).OrderByDescending(x => x.Id)
.GroupBy(x => new { x.field1, x.field2 })
.Select(x => new GetObj
{
field1 = x.Key.field1,
field2 = x.Key.field2,
totalQuantity = x.Sum(y => y.ldNet),
isMaped = x.Any(y => y.isLastMove == true)
}).ToList();
错误
.Any(y => y.isLastMove == True)' 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().