예제 #1
0
        public void QueryTtest()
        {
            var query = new SqlQuery("Table1 t1")
                .From(new SqlQuery("Table2").Select("Id"), "t2")
                .Select("t1.Name")
                .Where(Exp.EqColumns("t1.Id", "t2.Id"));

            Assert.AreEqual("select t1.Name from Table1 t1, (select Id from Table2) as t2 where t1.Id = t2.Id", query.ToString());
        }
예제 #2
0
        public void SqlUnionTest()
        {
            var union = new SqlQuery("t1").Select("c1").Where("c1", 4)
                .Union(new SqlQuery("t2").Select("c2").Where("c2", 7));

            Assert.AreEqual("select c1 from t1 where c1 = ? union select c2 from t2 where c2 = ?", union.ToString());
            Assert.AreEqual(4, union.GetParameters()[0]);
            Assert.AreEqual(7, union.GetParameters()[1]);
        }
예제 #3
0
 private static string BuildKey(SqlQuery q)
 {
     var s = new StringBuilder(q.ToString());
     foreach (var p in q.GetParameters())
     {
         if (p is IEnumerable)
         {
             foreach (var v in (IEnumerable)p)
             {
                 s.Append(v);
             }
         }
         else
         {
             s.Append(p);
         }
     }
     s.Append(SecurityContext.CurrentAccount.ID);//Append current account
     return Hasher.Base64Hash(s.ToString());
 }