示例#1
0
 private static Expression <Func <T, bool> > Combine <T>(Expression <Func <T, bool> > head, IEnumerable <Expression <Func <T, bool> > > tail, Func <Expression, Expression, BinaryExpression> combiner)
 {
     return(Enumerable.Aggregate <Expression <Func <T, bool> >, Expression <Func <T, bool> > >(tail, head, (Func <Expression <Func <T, bool> >, Expression <Func <T, bool> >, Expression <Func <T, bool> > >)((soFar, element) =>
     {
         Expression local_0 = LambdaSubstituter.ReplaceParameters((LambdaExpression)element, (IEnumerable <Expression>)soFar.Parameters);
         return (Expression <Func <T, bool> >)Expression.Lambda((Expression)combiner(soFar.Body, local_0), (IEnumerable <ParameterExpression>)soFar.Parameters);
     })));
 }
        private static Expression <Func <T, bool> > Combine <T>(Expression <Func <T, bool> > head, IEnumerable <Expression <Func <T, bool> > > tail, Func <Expression, Expression, BinaryExpression> combiner)
        {
            var result = tail.Aggregate(head, (soFar, element) =>
            {
                var lambda = LambdaSubstituter.ReplaceParameters(element, soFar.Parameters);
                return((Expression <Func <T, bool> >)Expression.Lambda(combiner(soFar.Body, lambda), soFar.Parameters));
            });

            return(result);
        }