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() { 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()); }