Skip to content

Conversation

@roji
Copy link
Member

@roji roji commented Dec 12, 2025

Fixes #35293

@roji roji marked this pull request as ready for review December 12, 2025 21:21
@roji roji requested a review from a team as a code owner December 12, 2025 21:21
@roji roji enabled auto-merge (squash) December 12, 2025 21:21
@AndriySvyryd AndriySvyryd disabled auto-merge January 3, 2026 02:13
Copilot AI review requested due to automatic review settings January 3, 2026 14:56
@roji roji enabled auto-merge (squash) January 3, 2026 14:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes issue #35293 by adding support for null comparisons on split entities. Previously, the code failed when comparing a split entity to null because it didn't handle the multiple table mappings that result from entity splitting.

Key Changes

  • Modified the null comparison logic to detect and handle entity splitting scenarios by selecting the principal table when multiple table mappings exist
  • Added test coverage to verify that comparing split entities to null generates correct SQL with proper INNER JOINs

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.StructuralEquality.cs Replaced the single mapping lookup with a switch expression that handles both single mappings and entity splitting (multiple mappings) by selecting the principal table
test/EFCore.Relational.Specification.Tests/Query/EntitySplittingQueryTestBase.cs Added base test that verifies split entity null comparisons work correctly with a simple entity splitting configuration
test/EFCore.SqlServer.FunctionalTests/Query/EntitySplittingQuerySqlServerTest.cs Added SQL Server-specific test override that validates the generated SQL correctly performs INNER JOINs between main and split tables

@roji roji merged commit 8540b89 into dotnet:main Jan 3, 2026
12 of 13 checks passed
@roji roji deleted the EntitySplittingCompareToNull branch January 3, 2026 15:40
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.

Entity splitting causes comparison to null to throw "Sequence contains more than one element"

2 participants