Basically I want to do the same thing as here: https://stackoverflow.com/a/16274992/4138686 , but using this answer in EF Core 3.1.3 gives me
System.InvalidOperationException: The LINQ expression '(GroupByShaperExpression: KeySelector: (r.Price), ElementSelector:(EntityShaperExpression: EntityType: RetailerRate ValueBufferExpression: (ProjectionBindingExpression: EmptyProjectionMember) IsNullable: False ) ) .OrderByDescending(r => r.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 either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
Here is the code:
await _db.RetailerRates
.GroupBy(r => r.Price)
.Select(g => g.OrderByDescending(r => r.CreatedAt).First())
.ToListAsync();
Is there a way to retrieve the first element based on a date from every group in EF Core 3.1?