コード例 #1
0
 public void complex_non_fluent_test()
 {
     var toBuild = "select id, name as b from products p join groups g on p.group_id=g.id left join stores s on g.id=s.group_id where (price>'100' and price<='1000') or code like 'a%' group by product_group having avg(price)>100 order by price desc";
     var fields = new List<SelectField>() { new SelectField("id"), new SelectField("name", "b") };
     var qbuilder = new SelectBuilder();
     qbuilder.Fields(fields).From("products", "p").Join("groups", "g", "p.group_id", "g.id").Join("stores", "s", "g.id", "s.group_id", JoinType.Left).OpenBracket()
         .Where("price", Compare.GreaterThan, 100).And.Where("price", Compare.LessOrEquals, 1000)
         .CloseBracket().Or.Where("code", Compare.Like, "a%")
         .GroupBy("product_group").Having("avg(price)>100").OrderByDesc("price").Build();
     Assert.Equal(toBuild.ToLower(), qbuilder.Build().ToLower());
 }
コード例 #2
0
 public void top_in_postgresql_test()
 {
     var toBuild = "select * from products limit 50";
     var query = new SelectBuilder().DB(DBType.PostreSql).AllFields.Top(50).From("products").Build();
     Assert.Equal(toBuild.ToLower(), query.ToLower());
 }