Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It seems like EF 9 has changed the way it handles subqueries that reference entity query root expressions.
In EF 8 when encountering a subquery like that, it calls
QueryCompiler
with the subquery whereExpand
is applied.In EF 9 it doesn't call the QueryCompiler for subqueries and so it throws an exception for unmapped projectable properties when it encounters them.
I've created a unit test that demonstrates the issue, and included the fix for it.
Essentially, expression replacer now expands all subqueries before replacing the expressions in them.
The code follows the same pattern used in efcore's ExpressionTreeFuncletizer.cs.
As part of this work, I've added net9.0 as a target for the test project, this way the library is tested against both
.NET8/EF8
and.NET9/EF9
combos.I've also updated nuget packages with vulnerabilities, since warnings are treated as errors.
As a side note, the query that fails is actually one that is generated by HotChocolate GraphQL library for paginated requests, which is how I came across it.
Looking forward to your feedback and suggestions.