Napisałem coś takiego:
var result =
await _dbContext.HistoricalOrder
.AsNoTracking()
.Where(x => x.RegistrationFormId == query.RegistrationFormId)
.GroupBy(x => x.RegistrationFormFlowId)
.Skip(((int)query.PaginationParameters.PageNumber - 1) * (int)query.PaginationParameters.PageSize)
.Take((int)query.PaginationParameters.PageSize)
.Select(x => new ChangeHistoryItemDto
{
CreatedAt = x.OrderByDescending(x => x.CreatedAt).FirstOrDefault().CreatedAt,
CreatedBy = $"{x.OrderByDescending(x => x.CreatedAt).FirstOrDefault().Creator.FirstName} {s.ToList().First().Creator.LastName}",
RegistrationFormFlowId = x.OrderByDescending(x => x.CreatedAt).FirstOrDefault().RegistrationFormFlowId
})
.OrderBy(x => x.CreatedAt)
.ToListAsync();
I dostaję coś takiego:
The LINQ expression 'GroupByShaperExpression:
KeySelector: h.RegistrationFormFlowId,
ElementSelector:EntityShaperExpression:
EntityType: HistoricalOrder
ValueBufferExpression:
ProjectionBindingExpression: EmptyProjectionMember
IsNullable: False
.OrderByDescending(x => x.CreatedAt)' 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
'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information
Jak rozwiązać ten problem?