Skip to content
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

Add .NET 9 + EF 9 support #124

Merged
merged 6 commits into from
Dec 7, 2024
Merged

Add .NET 9 + EF 9 support #124

merged 6 commits into from
Dec 7, 2024

Conversation

wassim-k
Copy link
Contributor

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 where Expand 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.

@wassim-k
Copy link
Contributor Author

wassim-k commented Dec 7, 2024

@koenbeuk, I've updated the target dotnet version in github workflow, so hopefully it should build now.

@koenbeuk
Copy link
Owner

koenbeuk commented Dec 7, 2024

Thanks! I've downgraded the .NET 8 dependencies as I don't think this library should force an update to the latest patch release.

@koenbeuk koenbeuk merged commit fbd2b8d into koenbeuk:master Dec 7, 2024
4 checks passed
@wassim-k wassim-k deleted the feature/ef9 branch December 8, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants