ionix.Data.SQLite 2.0.7

Incredibly easy and talented micro orm library for SQLite

Install-Package ionix.Data.SQLite -Version 2.0.7
dotnet add package ionix.Data.SQLite --version 2.0.7
<PackageReference Include="ionix.Data.SQLite" Version="2.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ionix.Data.SQLite --version 2.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

ionix is a micro-orm library that based on .net standart 2.0 (which supports Linux, Windows and macOS).

From NuGet

Install-Package ionix.Data

It' s very easy to use, here is some Northwind database examples:

Select Operations

using (var db = ionixFactory.CreateDbClient())
{
    var employee = db.Cmd.SelectById<Employees>(1);
    employee = await db.Cmd.SelectByIdAsync<Employees>(1);	
	
    var employee = dbCmd.QuerySingle<Employees>("select * from Employees where EmployeeID=@0".ToQuery(1)); 
    employee = await dbCmd.QuerySingleAsync<Employee>("select * from Employees where EmployeeID=@0".ToQuery(1));
	
    IList<Employees> employeeList = dbCmd.Query<Employees>("select * from Employees".ToQuery());
    employeeList = await dbCmd.QueryAsync<Employees>("select * from Employees".ToQuery());

    var q = @"select o.*, c.*, e.* from Orders o
              inner join Customers c on o.CustomerID = c.CustomerID
              inner join Employees e on o.EmployeeID = e.EmployeeID".ToQuery();
    var models = db.Cmd.Query<Orders, Customers, Employees>(q);
    models = await db.Cmd.QueryAsync<Orders, Customers, Employees>(q); 	
}

Select Operations #2

using (var db = ionixFactory.CreateDbClient())
{
    int regionId = db.Cmd.QuerySingle<int>("select top 1 RegionID from Region".ToQuery());
    
    IList<int> regionIds = db.Cmd.Query<int>("select RegionID from Region".ToQuery());

    dynamic customers = db.Cmd.QuerySingle<dynamic>("select top 1 * from Customers t".ToQuery());
    IList<dynamic> customers = db.Cmd.Query<dynamic>("select * from Customers t".ToQuery());

    IList<Categories> categories = (IList<Categories>)client.Cmd.QueryNonGeneric(typeof(Categories), "select top 3 * from Categories".ToQuery());
}

Update Operations

using (var db = ionixFactory.CreateTransactionalDbClient())
{
    Categories c = new Categories()
    {
        CategoryID = 8,
        CategoryName = "CategoryName",
    };

    int affected = db.Cmd.Update(c);
    affected = db.Cmd.Update(c, p => p.CategoryName);
    affected = await db.Cmd.UpdateAsync(c);

    IList<Categories> catagories = client.Cmd.Select<Categories>();
    db.Cmd.BatchUpdate(catagories);
    db.Cmd.BatchUpdate(catagories, p => p.CategoryName);
    await db.Cmd.BatchUpdateAsync(catagories);
     
    db.Commit();
}

Insert Operations

using (var db = ionixFactory.CreateTransactionalDbClient())
{
    Categories c = new Categories()
    {
        CategoryID = 0,
        CategoryName = "CategoryName",
    };

    int affected = db.Cmd.Insert(c);
    affected = await db.Cmd.InsertAsync(c);

    IList<Categories> catagories = client.Cmd.Select<Categories>();
    categories.ForEach((item) => item.CategoryID = 0);
    db.Cmd.BatchInsert(catagories);
    await db.Cmd.BatchInsertAsync(catagories);
     
    db.Commit();
}

Upsert Operations

using (var db = ionixFactory.CreateTransactionalDbClient())
{
    Categories c = new Categories()
    {
        CategoryID = 0,
        CategoryName = "CategoryName",
    };

    int affected = db.Cmd.Upsert(c);
    affected = db.Cmd.Upsert(c, p => p.CategoryName);
    affected = await db.Cmd.UpsertAsync(c);

    IList<Categories> catagories = client.Cmd.Select<Categories>();
    categories.ForEach((item) => item.CategoryID = 0);
    db.Cmd.BatchUpsert(catagories);
    db.Cmd.BatchUpsert(catagories, p => p.CategoryName);
    await db.Cmd.BatchUpsertAsync(catagories);
     
    db.Commit();
}

Delete Operations

using (var db = ionixFactory.CreateDbClient())
{
    Categories c = new Categories()
    {
        CategoryID = 3
    };

    int affected = db.Cmd.Delete(c);
    affected = await db.Cmd.DeleteAsync(c);
}

BulkCopy Operations

const int length = 1000000;
List<Region> list = new List<Region>(length);
for (int j = 0; j < length; ++j)
     list.Add(new Region() { RegionID = 1000 + j, RegionDescription = "dl" + j });

using (var db = ionixFactory.CreateDbClient())
{
    db.Cmd.BulkCopy(list);
    async db.Cmd.BulkCopyAsync(list); 
}

Which databases are supported?

Sql Server, Oracle, PostgreSQL (with migration / code-first approach) and SQLite.

You can check the ionix.DataTests project out for more details.

What about performance?

Maybe It's not perfectly accurate, but the picture gives you some insight about ionix's Performance;

ionix vs Entity Framework

("EF_Test" is Entity Framework' s Tests, "ionix_Tests" is ionix.Data' s Tests. All the tests run on Sql Server 2012)

ionix is a micro-orm library that based on .net standart 2.0 (which supports Linux, Windows and macOS).

From NuGet

Install-Package ionix.Data

It' s very easy to use, here is some Northwind database examples:

Select Operations

using (var db = ionixFactory.CreateDbClient())
{
    var employee = db.Cmd.SelectById<Employees>(1);
    employee = await db.Cmd.SelectByIdAsync<Employees>(1);	
	
    var employee = dbCmd.QuerySingle<Employees>("select * from Employees where EmployeeID=@0".ToQuery(1)); 
    employee = await dbCmd.QuerySingleAsync<Employee>("select * from Employees where EmployeeID=@0".ToQuery(1));
	
    IList<Employees> employeeList = dbCmd.Query<Employees>("select * from Employees".ToQuery());
    employeeList = await dbCmd.QueryAsync<Employees>("select * from Employees".ToQuery());

    var q = @"select o.*, c.*, e.* from Orders o
              inner join Customers c on o.CustomerID = c.CustomerID
              inner join Employees e on o.EmployeeID = e.EmployeeID".ToQuery();
    var models = db.Cmd.Query<Orders, Customers, Employees>(q);
    models = await db.Cmd.QueryAsync<Orders, Customers, Employees>(q); 	
}

Select Operations #2

using (var db = ionixFactory.CreateDbClient())
{
    int regionId = db.Cmd.QuerySingle<int>("select top 1 RegionID from Region".ToQuery());
    
    IList<int> regionIds = db.Cmd.Query<int>("select RegionID from Region".ToQuery());

    dynamic customers = db.Cmd.QuerySingle<dynamic>("select top 1 * from Customers t".ToQuery());
    IList<dynamic> customers = db.Cmd.Query<dynamic>("select * from Customers t".ToQuery());

    IList<Categories> categories = (IList<Categories>)client.Cmd.QueryNonGeneric(typeof(Categories), "select top 3 * from Categories".ToQuery());
}

Update Operations

using (var db = ionixFactory.CreateTransactionalDbClient())
{
    Categories c = new Categories()
    {
        CategoryID = 8,
        CategoryName = "CategoryName",
    };

    int affected = db.Cmd.Update(c);
    affected = db.Cmd.Update(c, p => p.CategoryName);
    affected = await db.Cmd.UpdateAsync(c);

    IList<Categories> catagories = client.Cmd.Select<Categories>();
    db.Cmd.BatchUpdate(catagories);
    db.Cmd.BatchUpdate(catagories, p => p.CategoryName);
    await db.Cmd.BatchUpdateAsync(catagories);
     
    db.Commit();
}

Insert Operations

using (var db = ionixFactory.CreateTransactionalDbClient())
{
    Categories c = new Categories()
    {
        CategoryID = 0,
        CategoryName = "CategoryName",
    };

    int affected = db.Cmd.Insert(c);
    affected = await db.Cmd.InsertAsync(c);

    IList<Categories> catagories = client.Cmd.Select<Categories>();
    categories.ForEach((item) => item.CategoryID = 0);
    db.Cmd.BatchInsert(catagories);
    await db.Cmd.BatchInsertAsync(catagories);
     
    db.Commit();
}

Upsert Operations

using (var db = ionixFactory.CreateTransactionalDbClient())
{
    Categories c = new Categories()
    {
        CategoryID = 0,
        CategoryName = "CategoryName",
    };

    int affected = db.Cmd.Upsert(c);
    affected = db.Cmd.Upsert(c, p => p.CategoryName);
    affected = await db.Cmd.UpsertAsync(c);

    IList<Categories> catagories = client.Cmd.Select<Categories>();
    categories.ForEach((item) => item.CategoryID = 0);
    db.Cmd.BatchUpsert(catagories);
    db.Cmd.BatchUpsert(catagories, p => p.CategoryName);
    await db.Cmd.BatchUpsertAsync(catagories);
     
    db.Commit();
}

Delete Operations

using (var db = ionixFactory.CreateDbClient())
{
    Categories c = new Categories()
    {
        CategoryID = 3
    };

    int affected = db.Cmd.Delete(c);
    affected = await db.Cmd.DeleteAsync(c);
}

BulkCopy Operations

const int length = 1000000;
List<Region> list = new List<Region>(length);
for (int j = 0; j < length; ++j)
     list.Add(new Region() { RegionID = 1000 + j, RegionDescription = "dl" + j });

using (var db = ionixFactory.CreateDbClient())
{
    db.Cmd.BulkCopy(list);
    async db.Cmd.BulkCopyAsync(list); 
}

Which databases are supported?

Sql Server, Oracle, PostgreSQL (with migration / code-first approach) and SQLite.

You can check the ionix.DataTests project out for more details.

What about performance?

Maybe It's not perfectly accurate, but the picture gives you some insight about ionix's Performance;

ionix vs Entity Framework

("EF_Test" is Entity Framework' s Tests, "ionix_Tests" is ionix.Data' s Tests. All the tests run on Sql Server 2012)

Release Notes

Some nuget packages updated.

Version History

Version Downloads Last updated
2.0.7 115 10/30/2018
2.0.5 158 6/5/2018
2.0.3 156 5/2/2018
2.0.2 158 5/2/2018
2.0.1 187 12/29/2017
2.0.0 196 12/7/2017
1.0.0 297 4/7/2016