-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature/netcore] Support aggregate on EF Core #1154
Comments
I just pulled the latest from @robward-ms's NetCore-Latest branch (7.0.0-...) and I am no longer receiving a 406 response but instead receive a 200 response with only a partial body:
It looks to be due to the following exception System.NotSupportedException: Could not parse expression '$it.AsQueryable()': This overload of the method 'System.Linq.Queryable.AsQueryable' is currently not supported.
Looks to be related to a re-linq issue but there appears to be a few workarounds (especially SO# 45326377).
|
@techniq - Yep, that falls more into the "Support EFCore", which is tracked by #669. The exception occurs during Apply. WebApi currently has some EF-specific code that needs to be updated for EFCore (at a minimum). If you want to follow #669, great. If you want to keep this issue open, I suggest we add "on EF Core" to the name. I'm fine with either, let me know your preference. |
@robward-ms I'd like to keep this issue open for now (and have added the "on EF Core" to the title) in case there are any workarounds or partial support we could put in place until full "EFCore" is complete. Some of those referenced links look like they had some success working around the issue, particularly this one. |
The main issue, Aggregation fails due to lack of AsQueryable support, tracked in EF Core 6132 has been fixed in version EF Core 2.1.0-preview2-30148. This allows aggregation to get passed the NotImplemented exception but aggregation still fails. Looks like the root cause is by lack of lazy-loading in EFCore:
OData WebApi expects that navigation properties can be loaded lazily. Using [EnableQuery] essential says "return to me a collection of something and I'll run queries against it for you". When those queries involve navigation properties, the lack of lazy loading causes the query to fail. I have a branch with the EFCore version of Aggregation tests + solution here: https://github.com/robward-ms/WebApi/tree/NetCore-E2ECore-EFCore |
@robward-ms so this is blocked until dotnet/efcore#3797 is implemented, but might not include navigational properties? It sounds like a pre-release of EF 2.1 was released with basic support for lazy loading, but it sounds like that might not be enough if I'm understanding your comment. |
@techniq - The pre-release of EF 2.1 was released with support for AsQueryable() but I'm not sure has support for lazy loading of navigation properties. Using the pre-release version, I can see that a single aggregation query is executing and gets the correct grouping but fails to calculate the sum of a property of a navigation property because the navigation property is null. So AsQueryable() gets EFCore and OData WebApi .Core closer to working together but does not resolve all the aggregation issues. This issue may not be blocked on aspnet/EntityFrameworkCore#3797 but more investigation is needed to determine if we can find a solution without it. Therefore, I tagged with "feature". |
Using core version 2.1.0 preview 1. Still getting this issue as mentioned above. {"@odata.context":"http://localhost:5000/odata/$metadata#Employees(AvgHoursPerWeek)","value":[ |
@xuzhg @robward-ms Not sure if this would help, but OdataToEntity supports $apply / aggregate for .NET Core / EF Core / ASP.NET Core. |
Btw, looks like this Test Suite is what needs enabled/passing (hard part being getting it passing) |
@xuzhg @biaol-odata any plans to have |
It appears using
$apply=aggregate(...)
on the alpha release of Microsoft.AspNetCore.OData is not supported.For example, the following works on WebApi 5.10.0 on .NET Framework:
/odata/Employees?$apply=aggregate(HoursPerWeek%20with%20average%20as%20AvgHoursPerWeek)
but returns a 406 (Not Acceptable) on Microsoft.AspNetCore.OData.dll, 7.0.0-Nightly201712061320 using .NET Core 2.0.
The text was updated successfully, but these errors were encountered: