我有一个数组
Expression<Func<MyClass,bool>>
然而,我想将它们全部AND在一起,以便只得到该类型的单个项目。我该怎么做?我可以强制转换Expression.And的结果吗?
我有一个数组
Expression<Func<MyClass,bool>>
public static Expression<Func<T, bool>> And<T> (this Expression<Func<T, bool>> expr1,
Expression<Func<T, bool>> expr2)
{
var invokedExpr = Expression.Invoke (expr2, expr1.Parameters.Cast<Expression> ());
return Expression.Lambda<Func<T, bool>>
(Expression.AndAlso (expr1.Body, invokedExpr), expr1.Parameters);
}
public Expression<Func<T, bool>> AggregateAnd(Expression<Func<T,bool>>[] input)
{
return input.Aggregate((l,r) => l.And(r));
}
Expression<Func<MyClass,bool>>
吗? - yamen