SQLite on Windows - activa/iridium GitHub Wiki
To use Velox.DB with SQLite in a regular Windows (desktop or server) application, add the Iridium Nuget package to your app. All required libraries will be installed, including the 32 bit and 64 bit native Sqlite DLLs.
var dbContext = new SqliteContext("Data\\my.db");
// ...
dbContext.CreateTable<Customer>();
//
dbContext.DataSet<Customer>().Save(new Customer { Name = "John" });
//
var johnCustomers = from c in dbContext.DataSet<Customer>()
where c.Name.StartsWith("John")
select c;
public class DbContext : SqliteContext
{
public DbContext() : base("Data\\my.db")
{
}
public IDataSet<Customer> Customers {get;set;}
public IDataSet<Product> Products {get;set;}
}
// ...
var dbContext = new DbContext();
//
dbContext.Customers.Save(new Customer { Name = "John" });
//
var johnCustomers = from c in dbContext.Customers
where c.Name.StartsWith("John")
select c;
You can also set the name of the database file later if you prefer (as long as you set it before the first data access):
public class DbContext : SqliteContext
{
public IDataSet<Customer> Customers {get;set;}
public IDataSet<Product> Products {get;set;}
}
// ...
var dbContext = new DbContext();
// ...
dbContext.FileName = "Data\\my.db";