예제 #1
0
        public static IQueryable GroupJoin(this IQueryable outer, IQueryable inner, Func <ParameterExpression, Expression> outerKeySelector, Func <ParameterExpression, Expression> innerKeySelector, Func <ParameterExpression, ParameterExpression, Expression> resultSelector)
        {
            var touter = outer.ElementType;
            var tinner = inner.ElementType;

            var outerKeySelectorExpr = ExpressionEx.Func(touter.AsParameter(), outerKeySelector);
            var innerKeySelectorExpr = ExpressionEx.Func(tinner.AsParameter(), innerKeySelector);
            var resultSelectorExpr   = ExpressionEx.Func(touter.AsParameter(), tinner.AsEnumerableType().AsParameter(), resultSelector);

            var tkey = outerKeySelectorExpr.ReturnType;

            return(outer.Transform(outer.CallQueryable("GroupJoin", new Type[] { touter, tinner, tkey, resultSelectorExpr.ReturnType }, inner.Expression, outerKeySelectorExpr.Quote(), innerKeySelectorExpr.Quote(), resultSelectorExpr.Quote())));
        }
예제 #2
0
        public static IQueryable GroupJoin(this IQueryable outer, IQueryable inner, LambdaExpression outerKeySelector, LambdaExpression innerKeySelector)
        {
            var touter = outer.ElementType;
            var tinner = inner.ElementType;
            var tkey   = outerKeySelector.ReturnType;

            var resultSelectorExpression = ExpressionEx.Func(
                touter.AsParameter(),
                typeof(IEnumerable <>).MakeGenericType(tinner).AsParameter(),
                (element, joinedElements) => GenericGroupJoinItem.CreateNewExpression(element, joinedElements)
                );

            return(outer.Transform(outer.CallQueryable("GroupJoin", new Type[] { touter, tinner, tkey, resultSelectorExpression.ReturnType }, inner.Expression, outerKeySelector.Quote(), innerKeySelector.Quote(), resultSelectorExpression.Quote())));
        }
예제 #3
0
        public static IQueryable Join(this IQueryable outer, IQueryable inner, LambdaExpression outerKeySelectorExpr, LambdaExpression innerKeySelectorExpr, Func <ParameterExpression, ParameterExpression, Expression> resultSelector = null)
        {
            var touter = outer.ElementType;
            var tinner = inner.ElementType;

            var tkey = outerKeySelectorExpr.ReturnType;

            if (resultSelector == null)
            {
                resultSelector = (left, right) => GenericJoinItem.CreateNewExpression(left, right);
            }

            var resultSelectorExpr = ExpressionEx.Func(touter.AsParameter(), tinner.AsParameter(), resultSelector);

            return(outer.Transform(outer.CallQueryable("Join", new Type[] { touter, tinner, tkey, resultSelectorExpr.ReturnType }, inner.Expression, outerKeySelectorExpr.Quote(), innerKeySelectorExpr.Quote(), resultSelectorExpr.Quote())));
        }
예제 #4
0
        public static IQueryable Join(this IQueryable outer, IQueryable inner, Func <ParameterExpression, Expression> outerKeySelector, Func <ParameterExpression, Expression> innerKeySelector, Func <ParameterExpression, ParameterExpression, Expression> resultSelector = null)
        {
            var touter = outer.ElementType;
            var tinner = inner.ElementType;

            return(outer.Join(inner, ExpressionEx.Func(touter.AsParameter(), outerKeySelector), ExpressionEx.Func(tinner.AsParameter(), innerKeySelector), resultSelector));
        }
예제 #5
0
        public static IQueryable Where(this IQueryable items, Func <ParameterExpression, Expression> predicate)
        {
            var res = items.Transform(items.CallQueryable("Where", Expression.Quote(ExpressionEx.Predicate(items.ElementType, predicate))));

            return(res);
        }