File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,20 @@ var count = await db.ExecuteScalarAsync<int>("select count(*) from Stock");
187187Console .WriteLine (string .Format (" Found '{0}' stock items." , count ));
188188```
189189
190+ ## Manual SQL
191+
192+ ** sqlite-net** is normally used as a light ORM with the methods ` CreateTable ` and ` Table ` . However, you can use it as just a convenient
193+ way to execute explicit queries.
194+
195+ Here is an example of create a table, inserting into it, and
196+ querying it without using the ORM.
197+
198+ ``` csharp
199+ db .Execute (" create table Stock(Symbol varchar(100) not null)" );
200+ db .Execute (" insert into Stock(Symbol) values (?)" , " MSFT" );
201+ var stocks = db .Query <Stock > (" select * from Stock" );
202+ ```
203+
190204## Using SQLCipher
191205
192206You can use an encrypted database by using the [ sqlite-net-sqlcipher NuGet package] ( https://www.nuget.org/packages/sqlite-net-sqlcipher ) .
Original file line number Diff line number Diff line change @@ -141,5 +141,18 @@ public void Cipher ()
141141 postKeyAction : db => db . Execute ( "PRAGMA kdf_iter = 128000;" ) ) ;
142142 var encryptedDb2 = new SQLiteAsyncConnection ( options2 ) ;
143143 }
144+
145+ [ Test ]
146+ public void Manual ( )
147+ {
148+ var db = new SQLiteConnection ( ":memory:" ) ;
149+
150+ db . Execute ( "create table Stock(Symbol varchar(100) not null)" ) ;
151+ db . Execute ( "insert into Stock(Symbol) values (?)" , "MSFT" ) ;
152+ var stocks = db . Query < Stock > ( "select * from Stock" ) ;
153+
154+ Assert . AreEqual ( 1 , stocks . Count ) ;
155+ Assert . AreEqual ( "MSFT" , stocks [ 0 ] . Symbol ) ;
156+ }
144157 }
145158}
You can’t perform that action at this time.
0 commit comments