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
Support $apply for EF Core #1728
Support $apply for EF Core #1728
Conversation
EF Core and EF6 need a bit different approach for aggregating IGrouping<>
@kosinsky @robward-ms is there anything stopping from releasing this fix? Im eagerly waiting for $apply 👍 |
@jannikbuschke, we have been working to release a few important updates in ODL so haven't reviewed this one yet. WebAPI's next release would be in march and i am hoping this PR will be part of that release. |
test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Aggregation/AggregationContextCore.cs
Outdated
Show resolved
Hide resolved
It seems good to me. @mikepizzo @KanishManuja-MS Would you take a look? |
src/Microsoft.AspNet.OData.Shared/Query/Expressions/AggregationBinder.cs
Outdated
Show resolved
Hide resolved
@@ -30,7 +30,7 @@ internal class AggregationBinder : ExpressionBinderBase | |||
|
|||
private Type _groupByClrType; | |||
|
|||
private bool _linqToObjectMode = false; | |||
private bool _classicEF = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that we effectively switch the default here, since _linqToObjectMode has the same default value, but the opposite behavior, of _classicEF. That's fine, as long as bind is called to explicitly set this value. I assume there are no scenarios where this value is used without first calling bind? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New default behavior is correct form .NET point of view. Expression like: object a = 15; must look like object a = (object) 15; on MSIL to do proper boxing or AccessViolationException will be thrown. Unfortunately, EF6 can't translate that to SQL. So we have to do hack for EF6. The same for IEnumerable and IGroupingBy
#Closed
src/Microsoft.AspNet.OData.Shared/Query/HandleNullPropagationOptionHelper.cs
Outdated
Show resolved
Hide resolved
3c4e142
to
dab67f1
Compare
@mikepizzo do you have any other feedback to this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this part of the current version of Microsoft.AspNetCore.OData ? |
It looks like the limitation here may be in EF in my case ... based on the above my query:
should be fine within odata, the exception given (as shown below) implies that this is a known issue with EF ...
|
Issues
This pull request fixes issues #1154 and #1257. Contributes to #669
Description
We are generating expressions that look like
Value type is object, as a result proper .NET expression must look like as
or AccessViolationException will be thrown when executing on real objects. On other hand, casts to object isn't translatable by EF6 as a result skipping (object) in that case.
We used to do that adjustment for Linq to Objects, EF Core could execute some parts client side and uses linq to object as result.
Also had to tune how aggregation on top of IGrouping works. Linq to Objects/EF Core and EF 6 has different limitations
Checklist (Uncheck if it is not completed)