I'm trying to retrieve the latest row in a group base on the CreatedDate
field.
How can this query be rewritten for EF Core 5 in a way which is not going to throw this Exception?
".OrderByDescending(s => s.CreatedDate)' 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'"?
Inserting AsEnumerable works, but this would be terrible solution.
var entries = _dbContext.MyTable
.GroupBy(s => s.Something)
.Select(g => g.OrderByDescending(s => s.CreatedDate).First())
.ToListAsync();