public void ToSqlTextTest03()
        {
            string expected = string.Empty;
            string actual = string.Empty;

            SQLWhereTextBuilder target = new SQLWhereTextBuilder();
            target.Set("aaa", SQLText.CompareOperation.Equal, DbType.Boolean, true);

            SQLWhereTextBuilder target1 = new SQLWhereTextBuilder();
            target1.Set("bbb", SQLText.CompareOperation.Equal, DbType.Double, 222);

            SQLWhereTextBuilder target2 = new SQLWhereTextBuilder();
            target2.Set("ccc", SQLText.CompareOperation.Equal, DbType.DateTime, DateTime.Parse("1999-9-9 9:9:9"));

            SQLWhereTextBuilder target3 = new SQLWhereTextBuilder();
            target3.Set("ddd", SQLText.CompareOperation.Equal, DbType.String, "DDD");

            target.Add(SQLText.LogicOperation.And, target1);
            target.Add(SQLText.LogicOperation.Or, target2);
            target.Add(SQLText.LogicOperation.Or, target3);

            expected = "(aaa = True AND bbb = 222 OR ccc = '1999-09-09 09:09:09.000' OR ddd = 'DDD')";
            actual = target.ToSqlText();
            Assert.AreEqual(expected, actual);
        }
        public void ToSqlTextTest02()
        {
            string expected = string.Empty;
            string actual = string.Empty;
            SQLWhereTextBuilder target = null;

            target = new SQLWhereTextBuilder();
            target.Set("aaa", SQLText.CompareOperation.MoreThan, DbType.Single, 22);
            expected = "aaa > 22";
            actual = target.ToSqlText();
            Assert.AreEqual(expected, actual);
        }
        public void ToSqlTextTest01()
        {
            string expected = string.Empty;
            string actual = string.Empty;
            SQLWhereTextBuilder target = null;

            target = new SQLWhereTextBuilder();
            target.Set("aaa", SQLText.CompareOperation.Equal, DbType.Boolean, true);
            expected = "aaa = True";
            actual = target.ToSqlText();
            Assert.AreEqual(expected, actual);
        }
        public void ToSqlTextTest01()
        {
            SQLWhereTextBuilder target = new SQLWhereTextBuilder();
            SQLInTextBuilder inb = new SQLInTextBuilder();
            inb.Set("a", "b", "c", "d");

            target.Set("abcd", SQLText.CompareOperation.In, System.Data.DbType.String, inb);

            string expected = "abcd IN ('a','b','c','d')";
            string actual;
            actual = target.ToSqlText();
            Assert.AreEqual(expected, actual);
        }
        public void ToSqlTextTest02()
        {
            SQLTextBuilder stb = new SQLTextBuilder();
            stb.Action = SQLText.Action.Select;
            stb.Field.Set("field1");
            stb.From.Set("DemoTable");

            SQLWhereTextBuilder target = new SQLWhereTextBuilder();
            SQLInTextBuilder inb = new SQLInTextBuilder();
            inb.Set(stb);

            target.Set("abcd", SQLText.CompareOperation.In, System.Data.DbType.String, inb);

            string expected = "abcd IN (SELECT field1 FROM DemoTable)";
            string actual;
            actual = target.ToSqlText();
            Assert.AreEqual(expected, actual);
        }
예제 #6
0
 /// <summary>
 /// 通过一个逻辑运算符(<see cref="LogicOperation"/>)给本类型连接一个逻辑条件。
 /// </summary>
 /// <param name="logicOper">一个逻辑运算符。</param>
 /// <param name="txtBuilder">一个逻辑条件。</param>
 public void Add(SQLText.LogicOperation logicOper, SQLWhereTextBuilder txtBuilder)
 {
     Operaters.Add(SQLText.LogicOperationFlags[(int)logicOper]);
     Conditions.Add(txtBuilder);
 }
 /// <summary>
 /// 通过一个逻辑运算符(<see cref="LogicOperation"/>)给本类型连接一个逻辑条件。
 /// </summary>
 /// <param name="logicOper">一个逻辑运算符。</param>
 /// <param name="txtBuilder">一个逻辑条件。</param>
 public void Add(SQLText.LogicOperation logicOper, SQLWhereTextBuilder txtBuilder)
 {
     Operaters.Add(SQLText.LogicOperationFlags[(int)logicOper]);
     Conditions.Add(txtBuilder);
 }