@@ -34,24 +34,18 @@ private class Installment
3434
3535 static void Main ( string [ ] args )
3636 {
37-
38- var query = new Query ( "accounts" ) . AsInsert ( new
37+ using ( var db = SqlLiteQueryFactory ( ) )
3938 {
40- name = "new Account" ,
41- currency_id = "USD" ,
42- created_at = DateTime . UtcNow ,
43- Value = SqlKata . Expressions . UnsafeLiteral ( "nextval('hello')" , replaceQuotes : false )
44- } ) ;
45-
46- var compiler = new SqlServerCompiler ( ) ;
47- var sql = compiler . Compile ( query ) . Sql ;
48- Console . WriteLine ( sql ) ;
39+ var query = db . Query ( "accounts" )
40+ . Where ( "balance" , ">" , 0 )
41+ . GroupBy ( "balance" )
42+ . Limit ( 10 ) ;
4943
44+ var accounts = query . Clone ( ) . Get ( ) ;
45+ Console . WriteLine ( JsonConvert . SerializeObject ( accounts , Formatting . Indented ) ) ;
5046
51- using ( var db = SqlLiteQueryFactory ( ) )
52- {
53- var accounts = db . Query ( "accounts" ) . Get ( ) ;
54- Console . WriteLine ( accounts . Count ( ) ) ;
47+ var exists = query . Clone ( ) . Exists ( ) ;
48+ Console . WriteLine ( exists ) ;
5549 }
5650 }
5751
@@ -81,7 +75,17 @@ private static QueryFactory SqlLiteQueryFactory()
8175
8276 SQLiteConnection . CreateFile ( "Demo.db" ) ;
8377
84- db . Statement ( "create table accounts(id integer primary key autoincrement, name varchar, currency_id varchar, created_at datetime);" ) ;
78+ db . Statement ( "create table accounts(id integer primary key autoincrement, name varchar, currency_id varchar, balance decimal, created_at datetime);" ) ;
79+ for ( var i = 0 ; i < 10 ; i ++ )
80+ {
81+ db . Statement ( "insert into accounts(name, currency_id, balance, created_at) values(@name, @currency, @balance, @date)" , new
82+ {
83+ name = $ "Account { i } ",
84+ currency = "USD" ,
85+ balance = 100 * i * 1.1 ,
86+ date = DateTime . UtcNow ,
87+ } ) ;
88+ }
8589
8690 }
8791
0 commit comments