[release/11.0] Fix projecting JSON complex collection together with collection navigation - #38948
Open
AndriySvyryd with Copilot wants to merge 1 commit into
Open
[release/11.0] Fix projecting JSON complex collection together with collection navigation#38948AndriySvyryd with Copilot wants to merge 1 commit into
AndriySvyryd with Copilot wants to merge 1 commit into
Conversation
…ation (#38928) Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot
AI
changed the title
[release/11.0] Fix projecting JSON complex collection together with collection navigation
Fix projecting JSON complex collection together with collection navigation
Sep 9, 2026
Copilot created this pull request from a session on behalf of
AndriySvyryd
September 9, 2026 20:59
View session
AndriySvyryd
marked this pull request as ready for review
September 9, 2026 21:59
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The fix aligns with the established index-based client projection remapping mechanism and is covered by new relational/spec plus provider baseline tests.
Pull request overview
Backports a relational query translation fix for projecting a JSON-mapped complex collection alongside a collection navigation in the same Select(), addressing an InvalidOperationException during client-projection remapping.
Changes:
- Fix index-based projection binding for
CollectionResultExpressionoverJsonQueryExpressionto bind using the_clientProjectionsindex. - Add a relational spec test covering the combined JSON complex collection + collection navigation projection scenario.
- Add provider-specific SQL baselines for SQL Server and SQLite for the new test.
File summaries
| File | Description |
|---|---|
| src/EFCore.Relational/Query/Internal/RelationalProjectionBindingExpressionVisitor.cs | Fixes index-based binding to return a ProjectionBindingExpression keyed by client-projection index for JSON complex collections. |
| test/EFCore.Relational.Specification.Tests/Query/ComplexTypeQueryRelationalTestBase.cs | Adds a regression test for projecting JSON complex collections together with a collection navigation under split query. |
| test/EFCore.SqlServer.FunctionalTests/Query/ComplexTypeQuerySqlServerTest.cs | Adds SQL Server baseline assertions for the new regression test. |
| test/EFCore.Sqlite.FunctionalTests/Query/ComplexTypeQuerySqliteTest.cs | Adds SQLite baseline assertions for the new regression test. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #38928
Backports #38932
Description
When a query projects a JSON complex collection (
ComplexCollection(...).ToJson()) together with a collection navigation in the sameSelect(), the index-based client-projection path added aProjectionBindingExpressionreferencing the collection's_projectionMembersposition instead of its position in_clientProjections. When both a JSON complex collection and a collection navigation are projected together,ClientProjectionRemappingExpressionVisitortries to look up the projection by that (wrong) index and finds no match, throwingInvalidOperationException: Nullable object must have a value.Customer impact
Any query that projects a JSON-mapped complex collection alongside a collection navigation in the same
Select()fails at translation time (even callingToQueryString()throws), so the query cannot be used at all. There's no workaround other than splitting the projections across multiple round trips.How found
User reported on 11.0.0-preview.7.
Regression
Yes, from 10.0.*, possibly exposed by #37552
Testing
Tests added
Risk
Low. The fix is a small, targeted change to the index-based binding branch for JSON complex collections, mirroring the pattern already used for JSON reference navigations a few lines above.