public void Process() { // (A = 5 AND ((A > 4 OR A < 5) AND (B <> 7 OR C IS NOT NULL)) AND S LIKE 'qwert' OR S NOT LIKE 'qwerty' AND A <= 9 AND Q >= 8) Criteria criteria = new Criteria("A", Clause.Eq, 5); Criteria criteria1 = new Criteria("A", Clause.Grate, 4).Or("A", Clause.Less, 5); Criteria criteria2 = new Criteria(LogicalOperator.And, "B", Clause.NotEq, 7).Or("C", Clause.IsNotNull); criteria.And(new Criteria(criteria1, criteria2)); criteria.And("S", Clause.Like, "qwert"); criteria.Or("S", Clause.NotLike, "qwerty"); criteria.And("A", Clause.NotGrate, 9).And("Q", Clause.NotLess, 8); criteria.And("E", Clause.NotIn, new[] { 1, 2, 3 }); StringCriteriaHandler criteriaHandler = new StringCriteriaHandler(ToStringConverter.Instance); criteria.Process(criteriaHandler); const string EXPECTED = "(A = 5 AND ((A > 4 OR A < 5) AND (B <> 7 OR C IS NOT NULL)) AND S LIKE 'qwert' OR S NOT LIKE 'qwerty' AND A <= 9 AND Q >= 8 AND E NOT IN (1, 2, 3))"; string actual = criteriaHandler.Expression; Assert.AreEqual(EXPECTED, actual); }
public Criteria And(Criteria criteria) { criteria.LogicalOperator = LogicalOperator.And; _criteriaList.Add(criteria); return this; }
public Criteria Or(Criteria criteria) { criteria.LogicalOperator = LogicalOperator.Or; _criteriaList.Add(criteria); return this; }
public void BeginCriteria(Criteria criteria) { AppendLogicaloperator(criteria.LogicalOperator); expression.Append(_LEFT_ROUND_BRACKET); }