SQLite is a lightweight, server-less database, it’s great for embedding into client application. It works across Windows, iOS, Android, browers.
Code snippets
Create database connection
var connection = new SQLiteAsyncConnection(“testdb.sqlite”);
Create table
await connection.CreateTableAync<MyClass>();
Insert Data
await connection.InsertAsync(new MyClass());
Build up your class
public class MyClass
{
[PrimaryKey]
public string Id { get; set; }
public DateTime CreatedOn { get; set; }
public string Name { get; set; }
[Ignore]
public ComplexClass IgnoreMe { get; set; }
}
Querying
var items = connection.Table<MyClass>()
.Where(x=>x.Name == “Bob”)
.FirstOrDefault();
Starting off
var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(“Assets\\dbfile.sqlite”);
try
{
await file.CopyAsync(ApplicationData.Current.LocalFolder);
}
catch
{
}
sqlite:
sqlite-net:
https://github.com/praeclarum/sqlite-net
sqlite-net-wp8:
https://github.com/peterhuene/sqlite-net-wp8
Sample: