Repository navigation
Translate Join/LeftJoin/RightJoin/FullJoin overloads without a result selector - #39612
Open
officialasishkumar wants to merge 1 commit into
Open
officialasishkumar wants to merge 1 commit into
officialasishkumar wants to merge 1 commit into
Conversation
… selector .NET 11 added Queryable.Join, LeftJoin, RightJoin and FullJoin overloads that take no result selector and return (TOuter Outer, TInner Inner) tuples. EF didn't recognize them, so queries using them failed translation. - Add QueryableMethods.JoinWithoutResultSelector, LeftJoinWithoutResultSelector, RightJoinWithoutResultSelector and FullJoinWithoutResultSelector. - In QueryableMethodNormalizingExpressionVisitor, rewrite a call to one of these overloads into the corresponding overload with a result selector that creates the ValueTuple: (o, i) => new ValueTuple<TOuter, TInner>(o, i). Accesses to the tuple's Outer/Inner members later in the query are folded back to the joined sources, so composing operators over the tuple translates as well. - A custom comparer isn't supported, as for the existing join overloads; such a call is left as is and fails translation. - Add specification tests for each overload, for composing over the tuple, for the Enumerable overload over a collection navigation and for a custom comparer, with SQL Server baselines and InMemory overrides for the right/full joins it doesn't support. Fixes dotnet#38047
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 #38047
.NET 11 added
Queryable.Join,LeftJoin,RightJoinandFullJoinoverloads without a result selector, which return(TOuter Outer, TInner Inner)tuples (dotnet/runtime#120596). EF didn't recognize them, so a query like the following failed with a translation error:Change
QueryableMethodNormalizingExpressionVisitornow rewrites these overloads to the existing overloads with a result selector that creates the tuple, next to theMinBy/MaxBynormalization:The same applies to
LeftJoin,RightJoinandFullJoin. The rest of the pipeline already handles this shape, so every provider that supports the corresponding join gets the translation:OuterandInnerareItem1andItem2of theValueTuple, so operators composed after the join are folded back to the joined sources through theValueTuplemember folding inReplacingExpressionVisitor(Fold ValueTuple/Tuple member access through constructor-bound projections #38560).Enumerableoverloads, for example over a collection navigation inside a projection, are converted to theQueryableones by the same visitor and are rewritten the same way.FullJoin): the call is left unchanged and fails translation.QueryableMethodsgetsJoinWithoutResultSelector,LeftJoinWithoutResultSelector,RightJoinWithoutResultSelectorandFullJoinWithoutResultSelector, following the existing...WithoutPredicate/...WithoutSelectornaming, with their API baseline entries.The selectorless
GroupJoinoverload from the same .NET release (dotnet/runtime#120587) isn't covered: it returnsIGroupingand, likeGroupJoinin general, needs different handling.Tests
New tests in
NorthwindJoinQueryTestBase: each of the four overloads (comparing the materializedOuter/Innerentities),Where/Selectcomposed over the tuple, theEnumerableoverload over a collection navigation, and a custom comparer (translation failure). They come with SQL Server baselines. On InMemory the right and full join tests assert a translation failure, like the existingRightJoin/FullJointests there.Without the change, all of them except the comparer test fail with a translation error. With it, I ran the
Microsoft.EntityFrameworkCore.Querytests on SQLite (17691 passed, 82 skipped) and InMemory (9414 passed, 43 skipped), theEFCore.Testsquery tests, andEFCoreApiBaselineTest. I couldn't run a SQL Server instance on my machine's architecture, so I generated the SQL Server baselines withToQueryString()onNorthwindSqlServerContextfor the same queries. For the matching existing tests (LeftJoin,RightJoin_with_filtered_outer,FullJoin_with_unmatched_rows_on_both_sides), this produces SQL identical to their committed baselines. The SQL Server test project builds.