OData / WebApi

OData Web API: A server library built upon ODataLib and WebApi
https://docs.microsoft.com/odata
Other
855 stars 473 forks source link

Aggregation extensions in OData ASP.NET Core fail when using SQL Server #2293

Open henrikdahl8240 opened 4 years ago

henrikdahl8240 commented 4 years ago

https://devblogs.microsoft.com/odata/aggregation-extensions-in-odata-asp-net-core/ shows how some typical everyday situations can be solved using OData.

I use SQL Server and not some in-memory stuff like the article deals with.

If I aim for doing a simple groupBy like http://localhost:5000/odata/Orders?$apply=groupby((Customer/Name), aggregate($count as OrderCount)) I receive an exception like:

System.InvalidOperationException: Processing of the LINQ expression 'GroupByShaperExpression:
...
' by 'RelationalProjectionBindingExpressionVisitor' failed. This may indicate either a bug or a limitation in EF Core. See https://go.microsoft.com/fwlink/?linkid=2101433 for more detailed information.

Do the constructions at https://devblogs.microsoft.com/odata/aggregation-extensions-in-odata-asp-net-core/ actually work as you use SQL Server.

I am using .NET 5.0 RC1 and Microsoft.AspnetCore.OData 7.4.1.

xuzhg commented 4 years ago

@kosinsky Do you have any insight?

kosinsky commented 4 years ago

It's the issue that I'm trying to solve here: https://github.com/OData/WebApi/pull/2179. PR does have solution for that case.

henrikdahl8240 commented 4 years ago

@kosinsky Have you also verified, that it works with casting, i.e. $apply=groupby((MyNamespace.MyDerivedType/PropertyOfMyDerivedType))?

... also in nested collections.

henrikdahl8240 commented 4 years ago

@xuzhg When do you think, that your nightly build may contain this PR?

xuzhg commented 4 years ago

@henrikdahl8240 Yes, I can do a nightly build for you to try.

xuzhg commented 4 years ago

@henrikdahl8240 Here's the nightly, you can find it using this version: '7.4.1-Nightly202009221831'

https://www.myget.org/feed/webapinetcore/package/nuget/Microsoft.AspNetCore.OData/7.4.1-Nightly202009221831