コード例 #1
0
 /// <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);
 }
コード例 #2
0
 /// <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);
 }
コード例 #3
0
 public void TestLessEqual()
 {
     _condition = SqlCondition.Create("a", "@", Operator.LessEqual);
     Assert.AreEqual("a<=@a", _condition.GetCondition());
 }
コード例 #4
0
 public void TestEnds()
 {
     _condition = SqlCondition.Create("a", "@", Operator.Ends);
     Assert.AreEqual("a Like @a", _condition.GetCondition());
 }
コード例 #5
0
 public void TestGreater()
 {
     _condition = SqlCondition.Create("a", "@", Operator.Greater);
     Assert.AreEqual("a>@a", _condition.GetCondition());
 }