Exemplo n.º 1
0
        public void RenderHavingClausesOr()
        {
            Column              column1              = new Column("Column1");
            Column              column2              = new Column("Column2");
            StringLiteralValue  stringLiteralValue1  = new StringLiteralValue("Value1");
            StringLiteralValue  stringLiteralValue2  = new StringLiteralValue("Value2");
            ComparisonPredicate comparisonPredicate1 = new ComparisonPredicate(column1, ComparisonPredicateType.Equals, stringLiteralValue1);
            ComparisonPredicate comparisonPredicate2 = new ComparisonPredicate(column2, ComparisonPredicateType.Equals, stringLiteralValue2);
            HavingClause        havingClause1        = new HavingClause(comparisonPredicate1);
            HavingClause        havingClause2        = new HavingClause(comparisonPredicate2);
            HavingClauses       havingClauses        = new HavingClauses(havingClause1, BooleanOperatorType.Or, havingClause2);

            Assert.AreEqual("([Column1] = 'Value1' OR [Column2] = 'Value2')", sqlClientRenderer.Render(havingClauses));
        }
Exemplo n.º 2
0
        public void AddHavingClauses()
        {
            Column              column1              = new Column("Column1");
            Column              column2              = new Column("Column2");
            StringLiteralValue  stringLiteralValue1  = new StringLiteralValue("Value1");
            StringLiteralValue  stringLiteralValue2  = new StringLiteralValue("Value2");
            ComparisonPredicate comparisonPredicate1 = new ComparisonPredicate(column1, ComparisonPredicateType.Equals, stringLiteralValue1);
            ComparisonPredicate comparisonPredicate2 = new ComparisonPredicate(column2, ComparisonPredicateType.Equals, stringLiteralValue2);
            HavingClause        havingClause1        = new HavingClause(comparisonPredicate1);
            HavingClause        havingClause2        = new HavingClause(comparisonPredicate2);
            HavingClauses       havingClauses        = new HavingClauses(havingClause1, BooleanOperatorType.And, havingClause2);

            Assert.AreEqual(havingClause1, havingClauses.LeftClause);
            Assert.AreEqual(BooleanOperatorType.And, havingClauses.OperatorType);
            Assert.AreEqual(havingClause2, havingClauses.RightClause);
        }
Exemplo n.º 3
0
        public override string Render(HavingClauses havingClauses)
        {
            if (havingClauses.LeftClause == null)
            {
                return(havingClauses.RightClause.Render(this));
            }
            else if (havingClauses.RightClause == null)
            {
                return(havingClauses.LeftClause.Render(this));
            }
            else
            {
                StringBuilder text = new StringBuilder();

                text.AppendFormat("({0} ", havingClauses.LeftClause.Render(this));

                text.AppendFormat("{0} ", havingClauses.OperatorType.ToString().ToUpper());

                text.AppendFormat("{0}) ", havingClauses.RightClause.Render(this));

                return(text.ToString().Trim());
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Adds the having.
 /// </summary>
 /// <param name="clause">The clause.</param>
 public void AddHaving(WhereClause clause)
 {
     HavingClauses.Add(clause);
 }
Exemplo n.º 5
0
 public abstract string Render(HavingClauses havingClauses);