如今是附加的,组合查询须要的扩展类。大家知道lanmda表达式的组合条件比較麻烦,所以就加了一样一个类,方便进行组合查询:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Linq.Expressions;namespace JFrame.AccessCommon{ public static class PredicateExtensions { public static Expression> True () { return f => true; } public static Expression > False () { return f => false; } public static Expression > Or (this Expression > expression1, Expression > expression2) { var invokedExpression = Expression.Invoke(expression2, expression1.Parameters.Cast ()); return Expression.Lambda >(Expression.Or(expression1.Body, invokedExpression), expression1.Parameters); } public static Expression > And (this Expression > expression1, Expression > expression2) { var invokedExpression = Expression.Invoke(expression2, expression1.Parameters.Cast ()); return Expression.Lambda >(Expression.And(expression1.Body, invokedExpression), expression1.Parameters); } }}