/// <summary> /// 过滤条件 /// </summary> /// <param name="name">列名</param> /// <param name="value">值</param> /// <param name="operator">运算符</param> public ISqlBuilder Filter(string name, object value, Operator @operator = Operator.Equal) { if (!IsValid(name, value)) { return(this); } And(SqlCondition.Create(name, GetParamPrefix(), @operator)); AddParam(name, value, @operator); return(this); }
/// <summary> /// 使用Or连接条件 /// </summary> /// <param name="condition">过滤条件</param> public ISqlBuilder Or(string condition) { if (condition.IsEmpty()) { return(this); } if (_condition == null) { _condition = SqlCondition.Create(condition); return(this); } _condition = new OrCondition(_condition.GetCondition(), condition); return(this); }
public void TestLessEqual() { _condition = SqlCondition.Create("a", "@", Operator.LessEqual); Assert.AreEqual("a<=@a", _condition.GetCondition()); }
public void TestEnds() { _condition = SqlCondition.Create("a", "@", Operator.Ends); Assert.AreEqual("a Like @a", _condition.GetCondition()); }
public void TestGreater() { _condition = SqlCondition.Create("a", "@", Operator.Greater); Assert.AreEqual("a>@a", _condition.GetCondition()); }