-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Calling static method in select and applying ToList produces wrong results. #7983
Comments
I investigated into this and this is bug in ReLinq's QueryParser. When we get the expression tree (after ParameterExtraction) the LambdaExpression in Select has Generated QueryModel.ToString
Point to mention that this does not happen if the new has any property assignment or anonymous type. |
@dmitryshunkov - As a workaround you can move defining new PostDTO from select clause. Effectively write query like this
|
@smitpatel to file a relinq bug on this |
@smitpatel Yes, an issue would be much approciated for bookkeeping. PS: Sorry, I thought that I already responded here but looks like it got lost in the inbox queue. I try to do a repro for this in the re-linq tests over the weekend but the next couple of weeks will be crazy for me so I can't make promises and I'll apologize in advance for any delays :) |
Filed issue on Re-Linq https://www.re-motion.org/jira/browse/RMLNQ-112 |
@smitpatel Just for bookkeeping: Thanks for the repro, it was a great tool for reminding me this can (and is meant to) be solved in EntityFramework using exisitng re-linq parsing infrastructure (IEvaluatableExpressionFilter). Please check the RMLNQ-112 issue for details. |
Closing this for now since the pattern is not super common and there is no easy solution that would not negatively impact other scenarios. We would consider re-opening this based on feedback from others hitting it. |
Re-opening this. Since we are removing ReLinq, we should look into supporting this kind of scenario. While this particular pattern may not be common, it is just a small subset of large scenario, in which user can call |
This may or may not work in 3.0 easily since even if Relinq is removed, our funcletizer may try to compute the value out for the initialization. |
@smitpatel to provide workaround. |
…ression tree This puts some of the processing (evaluating the expression to the corresponding constant) inside translation pipeline. - When applying EntityEquality, assumption here is that property is always going to be mapped on server side so we can generate constant. - When translating newExpression. If the generated constant can be mapped, it would work. (like new Datetime()) else translation would null out. Resolves #15712 Resolves #17048 Resolves #7983
…ression tree This puts some of the processing (evaluating the expression to the corresponding constant) inside translation pipeline. - When applying EntityEquality, assumption here is that property is always going to be mapped on server side so we can generate constant. - When translating newExpression. If the generated constant can be mapped, it would work. (like new Datetime()) else translation would null out. Resolves #15712 Resolves #17048 Resolves #7983
Inconsistent behavior when calling extension method for projection (f.e. for mapping to DTO) with and without ToList. Looks like closure behavior. If call ToList on Select with static extension method call it produces duplicate values.
Further technical details
EF Core version: 1.1.1
Database Provider: (Microsoft.EntityFrameworkCore.InMemory, Microsoft.EntityFrameworkCore.SqlServer)
Operating system: Windows 10
IDE: (e.g. Visual Studio 2017)
The text was updated successfully, but these errors were encountered: