-
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
Subquery.Any(predicateParameter) throws exception #8019
Comments
Error here is, we get Func in expression tree and we convert the closure into a parameter. Therefore we end up with |
@smitpatel Sorry, just to clarify, are you saying that EF should do reflection on the Func that's being passed as a parameter and it is supposed to create an Expression from it (in other words, it is a bug in EF), or are you saying that a client must pass a Lambda Expression, not a Func (i.e. the bug is in the client code)? |
@mikebridge - EF will not do reflection and look inside if you pass Func. |
@smitpatel thanks for the clarification! |
@smitpatel Edit: |
Any status update on this @smitpatel ? I'm hating having to repeat so much code because I can't create and reuse expressions for Where or nested Select |
I have wonderful update for this.
The issue here was when |
Regression test, which is same as above was added as part of #6132 |
That is great news @smitpatel I hope it will be released soon! |
Stackoverflow question: http://stackoverflow.com/questions/43057695/cant-extract-this-function-from-an-expression
Earlier discussion on #3722
from #3722 (comment)
@mikebridge wrote
I have subquery that is generating that same error, but only when the Func is passed into the method containing the query.
I have a "School" entity which contains "Program" entities, and I'm doing a subquery like the following---and this works fine:
However, I can't extract the "Where" function without generating an error. I think this should work the same:
Any idea why these are different? This is with EntityFrameworkCore 1.1.1.
#3722 (comment)
I'm sure I'm missing something obvious here. But it looks like I get the same error if I try to extract the Func from the Expression. This works when I pass it into my
SearchShoolPrograms
method:This doesn't:
I think they should be equivalent, but I'm still getting
System.NotSupportedException : Could not parse expression 'school.Programs.Any(__p_0)': The given arguments did not match the expected arguments: Object of type 'System.Linq.Expressions.TypedParameterExpression' cannot be converted to type 'System.Linq.Expressions.LambdaExpression'.
#3722 (comment)
@smitpatel sorry, yes, here it is:
@smitpatel If it helps, I created a test project that generates the error with an in-memory db.
The text was updated successfully, but these errors were encountered: