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

[Query] Always pass in Members when creating NewExpression #15536

Merged
merged 1 commit into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/EFCore/Query/NavigationExpansion/NavigationExpansionHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,14 @@ public static (Expression source, ParameterExpression parameter) AddNavigationJo
var groupJoinResultTransparentIdentifierCtorInfo
= groupJoinResultType.GetTypeInfo().GetConstructors().Single();

var groupJoinResultTransparentIdentifierOuterMemberInfo = groupJoinResultType.GetTypeInfo().GetDeclaredField("Outer");
smitpatel marked this conversation as resolved.
Show resolved Hide resolved
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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down