Cirreum.Persistence.SQLite 1.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Cirreum.Persistence.SQLite --version 1.0.4
                    
NuGet\Install-Package Cirreum.Persistence.SQLite -Version 1.0.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cirreum.Persistence.SQLite" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cirreum.Persistence.SQLite" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="Cirreum.Persistence.SQLite" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Cirreum.Persistence.SQLite --version 1.0.4
                    
#r "nuget: Cirreum.Persistence.SQLite, 1.0.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Cirreum.Persistence.SQLite@1.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Cirreum.Persistence.SQLite&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=Cirreum.Persistence.SQLite&version=1.0.4
                    
Install as a Cake Tool

Cirreum.Persistence.SQLite

NuGet Version NuGet Downloads GitHub Release License .NET

SQLite provider for Cirreum.Persistence.Sql

Overview

Cirreum.Persistence.SQLite is a SQLite-specific implementation of the ISqlConnectionFactory interface from the Cirreum.Persistence.Sql abstraction layer. It provides:

  • SQLite connection factory with Dapper integration
  • Health check support for service monitoring
  • Integration with the Cirreum Service Provider framework

For query extensions, pagination, transaction chaining, and constraint handling, see the Cirreum.Persistence.Sql documentation.

Installation

dotnet add package Cirreum.Persistence.SQLite

Quick Start

Basic Registration

builder.AddSqlite("default", "Data Source=mydb.sqlite");

With In-Memory Database

builder.AddSqlite("default", "Data Source=:memory:");

With Full Configuration

builder.AddSqlite("default", settings =>
{
    settings.ConnectionString = "Data Source=mydb.sqlite;Cache=Shared";
    settings.CommandTimeoutSeconds = 60;
}, healthOptions =>
{
    healthOptions.Query = "SELECT 1";
    healthOptions.Timeout = TimeSpan.FromSeconds(5);
});

Configuration Options

SqliteInstanceSettings

Property Type Default Description
ConnectionString string - SQLite connection string
CommandTimeoutSeconds int 30 Default command timeout in seconds

SqliteHealthCheckOptions

Property Type Default Description
Query string "SELECT 1" SQL query to execute for health checks
Timeout TimeSpan 5s Health check timeout

Usage

Inject ISqlConnectionFactory and use the query/command extensions from Cirreum.Persistence.Sql:

public class OrderRepository(ISqlConnectionFactory db)
{
    public async Task<Result<OrderDto>> GetOrderAsync(Guid orderId, CancellationToken ct)
    {
        await using var conn = await db.CreateConnectionAsync(ct);

        return await conn.GetAsync<OrderDto>(
            "SELECT * FROM Orders WHERE OrderId = @Id",
            new { Id = orderId },
            key: orderId,
            ct);
    }

    public async Task<Result<Guid>> CreateOrderAsync(CreateOrder cmd, CancellationToken ct)
    {
        await using var conn = await db.CreateConnectionAsync(ct);
        var orderId = Guid.CreateVersion7();

        return await conn.InsertAndReturnAsync(
            """
            INSERT INTO Orders (OrderId, CustomerId, Amount, CreatedAt)
            VALUES (@OrderId, @CustomerId, @Amount, @CreatedAt)
            """,
            new { OrderId = orderId, cmd.CustomerId, cmd.Amount, CreatedAt = DateTime.UtcNow },
            () => orderId,
            uniqueConstraintMessage: "Order already exists",
            ct: ct);
    }
}

Multiple Instances

Register multiple SQLite instances with different keys:

builder.AddSqlite("primary", "Data Source=primary.sqlite");
builder.AddSqlite("cache", "Data Source=cache.sqlite");

// Inject with [FromKeyedServices]
public class CacheService([FromKeyedServices("cache")] ISqlConnectionFactory db)
{
    // ...
}

DateOnly and TimeOnly Support

This package includes built-in Dapper type handlers for DateOnly and TimeOnly, allowing you to use these types directly in your models and queries:

public record Appointment(int Id, DateOnly Date, TimeOnly StartTime, TimeOnly EndTime);

// Query with DateOnly/TimeOnly parameters
var appointments = await conn.QueryAsync<Appointment>(
    "SELECT * FROM Appointments WHERE Date = @Date AND StartTime > @MinTime",
    new { Date = new DateOnly(2026, 1, 15), MinTime = new TimeOnly(9, 0) });

// Insert with DateOnly/TimeOnly values
await conn.ExecuteAsync(
    "INSERT INTO Appointments (Date, StartTime, EndTime) VALUES (@Date, @StartTime, @EndTime)",
    new { Date = DateOnly.FromDateTime(DateTime.Today), StartTime = new TimeOnly(9, 30), EndTime = new TimeOnly(10, 0) });

The type handlers are registered automatically when the package is loaded.

SQLite Connection Strings

Common SQLite connection string patterns:

Pattern Description
Data Source=mydb.sqlite File-based database
Data Source=:memory: In-memory database (single connection)
Data Source=mydb.sqlite;Cache=Shared Shared cache mode
Data Source=mydb.sqlite;Mode=ReadOnly Read-only mode
Data Source=mydb.sqlite;Password=secret Encrypted database
Package Description
Cirreum.Persistence.Sql Database-agnostic SQL abstraction layer
Cirreum.Persistence.SqlServer SQL Server provider
Cirreum.Persistence.MySql MySQL provider (coming soon)
Cirreum.Persistence.PostgreSql PostgreSQL provider (coming soon)

License

This project is licensed under the MIT License - see the LICENSE file for details.


Cirreum Foundation Framework Layered simplicity for modern .NET

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Cirreum.Persistence.SQLite:

Package Downloads
Cirreum.Runtime.Persistence

The Runtime Persistence service configuration.

Cirreum.Runtime.Persistence.SQLite

The Runtime Persistence service configuration for SQLite.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.5 120 2/5/2026
1.0.4 113 1/23/2026
1.0.3 94 1/22/2026
1.0.2 116 1/21/2026
1.0.1 115 1/12/2026
1.0.0 119 1/11/2026