public void ToSqlTextTest01()
        {
            string expected = "SELECT Field00, Field01 FROM Customs WHERE Id = '0011'";

            SQLTextBuilder target = new SQLTextBuilder();
            target.Action = SQLText.Action.Select;
            target.Field.Set("Field00", "Field01");
            target.From.Set("Customs");
            target.Where.Set("Id", SQLText.CompareOperation.Equal, DbType.String, "0011");

            Assert.AreEqual(expected, target.ToSqlText());
        }
        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);
        }
        public void ToSqlTextTest02()
        {
            string expected = "SELECT CustomerID, CompanyName, ContactTitle, City FROM Customers WHERE CustomerID IN (SELECT CustomerID FROM Orders)";

            SQLTextBuilder target = new SQLTextBuilder();
            target.Action = SQLText.Action.Select;
            target.Field.Set("CustomerID", "CompanyName", "ContactTitle", "City");
            target.From.Set("Customers");

            SQLTextBuilder ta = new SQLTextBuilder();
            ta.Action = SQLText.Action.Select;
            ta.Field.Set("CustomerID");
            ta.From.Set("Orders");

            SQLInTextBuilder inb = new SQLInTextBuilder();
            inb.Set(ta);

            target.Where.Set("CustomerID", SQLText.CompareOperation.In, DbType.String, inb);

            Assert.AreEqual(expected, target.ToSqlText());
        }
 public void Set(SQLTextBuilder builder)
 {
     this.Builder = builder;
 }
Exemple #5
0
 public void Set(SQLTextBuilder builder)
 {
     this.Builder = builder;
 }