diff --git a/src/EFCore/Query/NavigationExpansion/NavigationExpansionHelpers.cs b/src/EFCore/Query/NavigationExpansion/NavigationExpansionHelpers.cs index bee00020cb2..23e648e6ad3 100644 --- a/src/EFCore/Query/NavigationExpansion/NavigationExpansionHelpers.cs +++ b/src/EFCore/Query/NavigationExpansion/NavigationExpansionHelpers.cs @@ -143,8 +143,14 @@ public static (Expression source, ParameterExpression parameter) AddNavigationJo var groupJoinResultTransparentIdentifierCtorInfo = groupJoinResultType.GetTypeInfo().GetConstructors().Single(); + var groupJoinResultTransparentIdentifierOuterMemberInfo = groupJoinResultType.GetTypeInfo().GetDeclaredField("Outer"); + var groupJoinResultTransparentIdentifierInnerMemberInfo = groupJoinResultType.GetTypeInfo().GetDeclaredField("Inner"); + var groupJoinResultSelector = Expression.Lambda( - Expression.New(groupJoinResultTransparentIdentifierCtorInfo, resultSelectorOuterParameter, resultSelectorInnerParameter), + Expression.New( + groupJoinResultTransparentIdentifierCtorInfo, + new[] { resultSelectorOuterParameter, resultSelectorInnerParameter }, + new[] { groupJoinResultTransparentIdentifierOuterMemberInfo, groupJoinResultTransparentIdentifierInnerMemberInfo }), resultSelectorOuterParameter, resultSelectorInnerParameter); @@ -180,9 +186,15 @@ var groupJoinMethodCall var selectManyResultTransparentIdentifierCtorInfo = selectManyResultType.GetTypeInfo().GetConstructors().Single(); + var selectManyResultTransparentIdentifierOuterMemberInfo = selectManyResultType.GetTypeInfo().GetDeclaredField("Outer"); + var selectManyResultTransparentIdentifierInnerMemberInfo = selectManyResultType.GetTypeInfo().GetDeclaredField("Inner"); + // TODO: dont reuse parameters here? var selectManyResultSelector = Expression.Lambda( - Expression.New(selectManyResultTransparentIdentifierCtorInfo, selectManyCollectionSelectorParameter, innerKeySelectorParameter), + Expression.New( + selectManyResultTransparentIdentifierCtorInfo, + new[] { selectManyCollectionSelectorParameter, innerKeySelectorParameter }, + new[] { selectManyResultTransparentIdentifierOuterMemberInfo, selectManyResultTransparentIdentifierInnerMemberInfo }), selectManyCollectionSelectorParameter, innerKeySelectorParameter); @@ -220,8 +232,14 @@ var selectManyMethodCall var transparentIdentifierCtorInfo = resultType.GetTypeInfo().GetConstructors().Single(); + var transparentIdentifierOuterMemberInfo = resultType.GetTypeInfo().GetDeclaredField("Outer"); + var transparentIdentifierInnerMemberInfo = resultType.GetTypeInfo().GetDeclaredField("Inner"); + var resultSelector = Expression.Lambda( - Expression.New(transparentIdentifierCtorInfo, resultSelectorOuterParameter, resultSelectorInnerParameter), + Expression.New( + transparentIdentifierCtorInfo, + new[] { resultSelectorOuterParameter, resultSelectorInnerParameter }, + new[] { transparentIdentifierOuterMemberInfo, transparentIdentifierInnerMemberInfo }), resultSelectorOuterParameter, resultSelectorInnerParameter); diff --git a/src/EFCore/Query/NavigationExpansion/Visitors/NavigationExpandingVisitor_MethodCall.cs b/src/EFCore/Query/NavigationExpansion/Visitors/NavigationExpandingVisitor_MethodCall.cs index dc148f15dd7..85080eaa267 100644 --- a/src/EFCore/Query/NavigationExpansion/Visitors/NavigationExpandingVisitor_MethodCall.cs +++ b/src/EFCore/Query/NavigationExpansion/Visitors/NavigationExpandingVisitor_MethodCall.cs @@ -632,8 +632,14 @@ private Expression ProcessGroupJoin(MethodCallExpression methodCallExpression) outerApplyOrderingsResult.state.CustomRootMappings.Concat(new[] { groupingMapping }).ToList(), materializeCollectionNavigation: null); + var transparentIdentifierOuterMemberInfo = resultType.GetTypeInfo().GetDeclaredField("Outer"); + var transparentIdentifierInnerMemberInfo = resultType.GetTypeInfo().GetDeclaredField("Inner"); + var lambda = Expression.Lambda( - Expression.New(transparentIdentifierCtorInfo, outerApplyOrderingsResult.state.CurrentParameter, newGroupingParameter), + Expression.New( + transparentIdentifierCtorInfo, + new[] { outerApplyOrderingsResult.state.CurrentParameter, newGroupingParameter }, + new[] { transparentIdentifierOuterMemberInfo, transparentIdentifierInnerMemberInfo }), outerApplyOrderingsResult.state.CurrentParameter, newGroupingParameter); @@ -1354,8 +1360,14 @@ protected override Expression VisitConstant(ConstantExpression constantExpressio outerState.CustomRootMappings.Concat(innerState.CustomRootMappings).ToList(), materializeCollectionNavigation: null); + var transparentIdentifierOuterMemberInfo = resultType.GetTypeInfo().GetDeclaredField("Outer"); + var transparentIdentifierInnerMemberInfo = resultType.GetTypeInfo().GetDeclaredField("Inner"); + var lambda = Expression.Lambda( - Expression.New(transparentIdentifierCtorInfo, outerState.CurrentParameter, innerState.CurrentParameter), + Expression.New( + transparentIdentifierCtorInfo, + new[] { outerState.CurrentParameter, innerState.CurrentParameter }, + new[] { transparentIdentifierOuterMemberInfo, transparentIdentifierInnerMemberInfo }), outerState.CurrentParameter, innerState.CurrentParameter);