This query worked fine in EF Core 2
datacontext.data_Rewards.GroupBy(x => x.RewardGameType, (key, g) => g.OrderByDescending(e =>e.RewardPriority).FirstOrDefault()).ToList();``
in EF Core 3 it fails with
nvalidOperationException: The LINQ expression 'OrderByDescending<data_Rewards, int>( source: GroupByShaperExpression: KeySelector: d.RewardGameType, ElementSelector:EntityShaperExpression: EntityType: data_Rewards ValueBufferExpression: ProjectionBindingExpression: EmptyProjectionMember IsNullable: False , keySelector: (e) => e.RewardPriority)' 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.
The original query produced an orderby SQL query and another group by query.
Is there a way to at least turn back this default behavior or does one simply have to fix all the queries and make them work so they're correctly evaluated in sql server in a sinqle query?
I did rewrite this one but...I'm just afraid that a lot of queries might now just fail after updating
This query worked fine in EF Core 2
datacontext.data_Rewards.GroupBy(x => x.RewardGameType, (key, g) => g.OrderByDescending(e =>
e.RewardPriority).FirstOrDefault()).ToList();`` in EF Core 3 it fails withnvalidOperationException: The LINQ expression 'OrderByDescending<data_Rewards, int>( source: GroupByShaperExpression: KeySelector: d.RewardGameType, ElementSelector:EntityShaperExpression: EntityType: data_Rewards ValueBufferExpression: ProjectionBindingExpression: EmptyProjectionMember IsNullable: False , keySelector: (e) => e.RewardPriority)' 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.
The original query produced an orderby SQL query and another group by query. Is there a way to at least turn back this default behavior or does one simply have to fix all the queries and make them work so they're correctly evaluated in sql server in a sinqle query?
I did rewrite this one but...I'm just afraid that a lot of queries might now just fail after updating