You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Also add one of the https://github.com/ericsink/SQLitePCL.raw package of your choice to the netstandard project:
9
-
- SQLitePCLRaw.bundle_e_sqlite3 for a normal database file
10
-
- SQLitePCLRaw.bundle_e_sqlcipher for a crypted database file
8
+
**Required**: add ONLY ONE of the followin packages to your common project:
9
+
-[SQLitePCLRaw.bundle_e_sqlite3](https://www.nuget.org/packages/SQLitePCLRaw.bundle_e_sqlite3) for a normal database file
10
+
-[SQLitePCLRaw.bundle_e_sqlcipher](https://www.nuget.org/packages/SQLitePCLRaw.bundle_e_sqlcipher) for an encrypted database file
11
11
12
-
And call this statup function in each of your platform projects:
12
+
Then call the init method once. That can be in your App.cs:
13
13
14
-
```csharp
14
+
```c#
15
15
SQLitePCL.Batteries_V2.Init()
16
16
```
17
17
18
-
For a simple key/value store based on sqlite, or a drop-in replacement (alternative) to the unstable Akavache, check https://github.com/softlion/KeyValueLite
19
-
20
18
# Features
21
19
22
20
* Netstandard 2+
23
21
* Uses SQLitePCLRaw for sqlite raw communication
24
22
* Compatible with SQLitePCLRaw standard and cypher
25
23
* Stable and used in tons of apps
26
24
25
+
For a key/value store based on sqlite, or a drop-in replacement (alternative) to the unstable Akavache, check [KeyValueLite](https://github.com/softlion/KeyValueLite)
26
+
27
27
# Other Features (compared to oysteinkrog)
28
28
29
29
* Multiple primary key support
30
30
Ex:
31
-
```csharp
32
-
publicclassPrivacyGroupItem
33
-
{
34
-
[PrimaryKey]
35
-
publicintGroupId {get;set;}
36
-
37
-
[PrimaryKey]
38
-
publicintContactId {get;set;}
39
-
}
40
-
41
-
db.Delete<PrivacyGroupItem>(groupId, contactId);
42
-
```
31
+
```c#
32
+
publicclassPrivacyGroupItem
33
+
{
34
+
[PrimaryKey]
35
+
publicintGroupId {get;set;}
36
+
37
+
[PrimaryKey]
38
+
publicintContactId {get;set;}
39
+
}
40
+
41
+
db.Delete<PrivacyGroupItem>(groupId, contactId);
42
+
```
43
43
44
44
* Projections now have the expected result type
45
45
Ex: `IEnumerable<int> ids = from pgi in db.Table<PrivacyGroupItem>() where pgi.PrivacyGroupId == groupId select pgi.ContactId;`
@@ -64,7 +64,7 @@ Note: see unit tests for more examples.
64
64
65
65
## Define the database schema using a code first approach.
66
66
67
-
```csharp
67
+
```c#
68
68
publicclassDbStock
69
69
{
70
70
[PrimaryKey, AutoIncrement]
@@ -92,7 +92,7 @@ Note: see unit tests for more examples.
@@ -122,7 +122,7 @@ Note: see unit tests for more examples.
122
122
123
123
Simple add, update and delete:
124
124
125
-
```csharp
125
+
```c#
126
126
varstock=newDbStock() { Symbol="EUR" };
127
127
db.Insert(stock);
128
128
stock.Symbol="USD";
@@ -140,7 +140,7 @@ After the Insert call, stock.Id will be set, because Id has the AutoIncrement at
140
140
141
141
Simple query using LINQ. Most linq operators work:
142
142
143
-
```csharp
143
+
```c#
144
144
varstocksStartingWithA=db.Table<DbStock>()
145
145
.Where(stock=>stock.Symbol.StartsWith("A"))
146
146
.OrderBy(stock=>stock.Symbol)
@@ -151,14 +151,14 @@ Simple query using LINQ. Most linq operators work:
151
151
152
152
Advanced queries using SQL:
153
153
154
-
```csharp
154
+
```c#
155
155
vardbValuation=db.Query<DbValuation> ("select * from DbValuation where StockId = ?", stock.Id);
156
156
db.Execute("delete * from DbValuation where StockId = ?", stock.Id);
157
157
```
158
158
159
159
The T in `db.Query<T>` specifies the object to create for each row. It can be a table class, or any other class whose public properties match the query columns.
160
160
161
-
```csharp
161
+
```c#
162
162
publicclassVal {
163
163
publicdecimalMoney { get; set; }
164
164
publicDateTimeDate { get; set; }
@@ -169,15 +169,17 @@ The T in `db.Query<T>` specifies the object to create for each row. It can be a
169
169
}
170
170
```
171
171
172
-
## Encrypting the database file
173
-
174
-
Add the nuget `SQLitePCLRaw.bundle_e_sqlcipher` to your project containing `sqlite-net2`.
172
+
## Using an encrypted database file
175
173
176
-
Call this right after opening or creating the db, as the 1st instruction.
174
+
Add the nuget [SQLitePCLRaw.bundle_e_sqlcipher](https://www.nuget.org/packages/SQLitePCLRaw.bundle_e_sqlcipher) to your common project.
175
+
Then add this code right after opening or creating the db, and before any other db call:
0 commit comments