public Queryable <T> Where(Expression <Func <T, object> > field, Operator op, object value) { LogicalBinaryExpression logical; switch (op) { case Operator.Equal: logical = SqlExpression.Equal(field, value); break; case Operator.LessThan: logical = SqlExpression.LessThan(field, value); break; case Operator.LessThanOrEqual: logical = SqlExpression.LessThanOrEqual(field, value); break; case Operator.GreaterThan: logical = SqlExpression.GreaterThan(field, value); break; case Operator.GreaterThanOrEqual: logical = SqlExpression.GreaterThanOrEqual(field, value); break; case Operator.In: logical = SqlExpression.In(field, value); break; case Operator.StartWith: logical = SqlExpression.Like(field, value, true, false); break; case Operator.EndWith: logical = SqlExpression.Like(field, value, false, true); break; case Operator.Like: logical = SqlExpression.Like(field, value, true, true); break; case Operator.NotEqual: logical = SqlExpression.NotEqual(field, value); break; case Operator.Between: var values = ((ICollection)value).Cast <object>(); if (values.Count() < 2) { throw new ArgumentException("value集合未包含两个元素。"); } logical = SqlExpression.Between(field, values.First(), values.Skip(1).First()); break; case Operator.NotIn: logical = SqlExpression.NotIn(field, value); break; default: throw new NotSupportedException(string.Format("不受支持的{0}", op)); } return(Where(logical)); }