OData / OData/AspNetCoreOData

Apply/GroupBy/Aggregate in .NET 5 / Odata v8preview3 / EFCore 5 doesn't work

Open
#76 25 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

investigating
Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

Hello,

I have problems with Apply/GroupBy/Aggregate in .NET 5 / Odata v8preview3 / EFCore 5.

I'm not able to use simple expression like $apply=aggregate($count as OrderCount).

I receive the following error:

System.InvalidOperationException: Processing of the LINQ expression 'GroupByShaperExpression:
      KeySelector: new NoGroupByWrapper(),
      ElementSelector:EntityShaperExpression:
          EntityType: OperationExecution
          ValueBufferExpression:
              ProjectionBindingExpression: EmptyProjectionMember
          IsNullable: False
      ' by 'RelationalProjectionBindingExpressionVisitor' failed. 
This may indicate either a bug or a limitation in Entity Framework. 

Can you help me to resolve this problem?

Obviously for me, it's not a solution to use ToList() and aggregate client side.

Thanks

Fabio

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing $apply=aggregate($count as OrderCount) with .NET 5, ASP.NET Core OData v8preview3, and EF Core 5, then inspect where the GroupByShaperExpression reaches EF Core's relational projection handling. Done means server-side aggregation works without ToList() or client-side processing, with the reported exception no longer occurring.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.