private MethodCallExpression Build(Expression outerSource, Expression innerSource, IReadOnlyList <IEdmNavigationProperty> joinPath, IEdmNavigationProperty navigationProperty, bool manyToMany) { Type outerType = OeExpressionHelper.GetCollectionItemType(outerSource.Type); Type innerType = OeExpressionHelper.GetCollectionItemType(innerSource.Type); LambdaExpression groupJoinOuterKeySelector = GetGroupJoinOuterKeySelector(outerType, navigationProperty, joinPath); LambdaExpression groupJoinInnerKeySelector = GetGroupJoinInnerKeySelector(innerType, navigationProperty); if (groupJoinOuterKeySelector.ReturnType != groupJoinInnerKeySelector.ReturnType) { Expression innerBody = CoerceExpression(groupJoinOuterKeySelector.Body, groupJoinInnerKeySelector.Body); if (innerBody.Type != groupJoinInnerKeySelector.ReturnType) { groupJoinInnerKeySelector = Expression.Lambda(innerBody, groupJoinInnerKeySelector.Parameters[0]); } if (innerBody.Type != groupJoinOuterKeySelector.ReturnType) { Expression outerBody = CoerceExpression(innerBody, groupJoinOuterKeySelector.Body); groupJoinOuterKeySelector = Expression.Lambda(outerBody, groupJoinOuterKeySelector.Parameters[0]); } } LambdaExpression groupJoinResultSelect = GetGroupJoinResultSelector(outerType, innerType, manyToMany); MethodInfo groupJoinMethodInfo = OeMethodInfoHelper.GetGroupJoinMethodInfo(outerType, innerType, groupJoinOuterKeySelector.ReturnType, groupJoinResultSelect.ReturnType); MethodCallExpression groupJoinCall = Expression.Call(groupJoinMethodInfo, outerSource, innerSource, groupJoinOuterKeySelector, groupJoinInnerKeySelector, groupJoinResultSelect); LambdaExpression selectManySource = GetSelectManyCollectionSelector(groupJoinResultSelect); LambdaExpression selectManyResultSelector = GetSelectManyResultSelector(groupJoinResultSelect); MethodInfo selectManyMethodInfo = OeMethodInfoHelper.GetSelectManyMethodInfo(groupJoinResultSelect.ReturnType, innerType, selectManyResultSelector.ReturnType); return(Expression.Call(selectManyMethodInfo, groupJoinCall, selectManySource, selectManyResultSelector)); }
private MethodCallExpression Build(Expression outerSource, Expression innerSource, IReadOnlyList <IEdmNavigationProperty> joinPath, IEdmNavigationProperty navigationProperty, bool manyToMany) { Type outerType = OeExpressionHelper.GetCollectionItemType(outerSource.Type); Type innerType = OeExpressionHelper.GetCollectionItemType(innerSource.Type); (LambdaExpression groupJoinOuterKeySelector, LambdaExpression groupJoinInnerKeySelector) = GetJoinKeySelector(outerType, innerType, joinPath, navigationProperty); LambdaExpression groupJoinResultSelect = GetGroupJoinResultSelector(outerType, innerType, manyToMany); MethodInfo groupJoinMethodInfo = OeMethodInfoHelper.GetGroupJoinMethodInfo(outerType, innerType, groupJoinOuterKeySelector.ReturnType, groupJoinResultSelect.ReturnType); MethodCallExpression groupJoinCall = Expression.Call(groupJoinMethodInfo, outerSource, innerSource, groupJoinOuterKeySelector, groupJoinInnerKeySelector, groupJoinResultSelect); LambdaExpression selectManySource = GetSelectManyCollectionSelector(groupJoinResultSelect); LambdaExpression selectManyResultSelector = GetSelectManyResultSelector(groupJoinResultSelect); MethodInfo selectManyMethodInfo = OeMethodInfoHelper.GetSelectManyMethodInfo(groupJoinResultSelect.ReturnType, innerType, selectManyResultSelector.ReturnType); return(Expression.Call(selectManyMethodInfo, groupJoinCall, selectManySource, selectManyResultSelector)); }