SQLiteM.Abstractions 0.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package SQLiteM.Abstractions --version 0.1.1
                    
NuGet\Install-Package SQLiteM.Abstractions -Version 0.1.1
                    
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="SQLiteM.Abstractions" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SQLiteM.Abstractions" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="SQLiteM.Abstractions" />
                    
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 SQLiteM.Abstractions --version 0.1.1
                    
#r "nuget: SQLiteM.Abstractions, 0.1.1"
                    
#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 SQLiteM.Abstractions@0.1.1
                    
#: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=SQLiteM.Abstractions&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=SQLiteM.Abstractions&version=0.1.1
                    
Install as a Cake Tool

SQLiteM

Leichtgewichtiges, SOLID-konformes Micro-ORM für SQLite (C#/.NET).
Fokus: minimale Magie, transparente SQL-Generierung, Repository + Unit of Work, Foreign Keys.

Dieses Repository enthält zwei Pakete:

  • SQLiteM.Abstractions – öffentliche Attribute, Interfaces und Record-Typen
  • SQLiteM.Orm – Implementierung: Repository, UnitOfWork, Dialekt, Reflection-Mapper, Bootstrap, Client-Fassade

Features

  • Attribute-Mapping: [Table], [Column], [PrimaryKey], [AutoIncrement], [ForeignKey], [Ignore]
  • Repository + Unit of Work
  • DDL-Generierung (EnsureCreated) inkl. Fremdschlüssel
  • Einfache Query-API (Query.WhereEquals(...).OrderBy(...))
  • Foreign Keys standardmäßig aktiv (PRAGMA foreign_keys = ON)
  • Optionaler High-Level-Client SQLiteMClient (Transaktionen in einer Zeile)
  • Saubere Trennung: Abstraktionen separat, Implementierungen intern

Installation (NuGet)

Sobald veröffentlicht:

dotnet add package SQLiteM.Abstractions
dotnet add package SQLiteM.Orm

Getting Started

1) Services registrieren (DI)

using Microsoft.Extensions.DependencyInjection;
using SQLiteM.Abstractions;
using SQLiteM.Orm;

var dbPath = Path.Combine(AppContext.BaseDirectory, "app.db");
var cs = $"Data Source={dbPath};Cache=Shared";

var services = new ServiceCollection()
    .AddSQLiteM(o => o.ConnectionString = cs)
    .BuildServiceProvider();

2) Entitäten definieren

using SQLiteM.Abstractions;

[Table("persons")]
public sealed class Person
{
    [PrimaryKey, AutoIncrement]
    [Column("id")]
    public long Id { get; set; }

    [Column("first_name", IsNullable = false, Length = 100)]
    public string FirstName { get; set; } = default!;

    [Column("last_name", IsNullable = false, Length = 100)]
    public string LastName { get; set; } = default!;

    [Column("email", IsNullable = true, Length = 255)]
    public string? Email { get; set; }
}

3) Schema erzeugen

await using (var uow = await services.GetRequiredService<IUnitOfWorkFactory>().CreateAsync())
{
    var builder = services.GetRequiredService<ISqlBuilder>();
    await SQLiteM.Orm.Pub.SQLiteMBootstrap.EnsureCreatedAsync<Person>(uow, builder);
    await uow.CommitAsync();
}

4) CRUD

await using (var uow = await services.GetRequiredService<IUnitOfWorkFactory>().CreateAsync())
{
    var repo = services.GetRequiredService<IRepositoryFactory>().Create<Person>(uow);

    var id = await repo.InsertAsync(new Person
    {
        FirstName = "Ada",
        LastName  = "Lovelace",
        Email     = "ada@example.com"
    });

    var p = await repo.FindByIdAsync(id);
    p!.Email = "ada.lovelace@history.org";
    await repo.UpdateAsync(p);

    await repo.DeleteAsync(id);
    await uow.CommitAsync();
}

High-Level Client (SQLiteMClient)

Falls du ohne DI auskommen möchtest:

using SQLiteM.Orm.Pub;

var client = new SQLiteMClient(Path.Combine(AppContext.BaseDirectory, "app.db"));

await client.EnsureCreatedAsync<Person>();

var id = await client.InsertAsync(new Person { FirstName = "Grace", LastName = "Hopper" });

await client.WithTransactionAsync(async tx =>
{
    var rp = tx.Repo<Person>();
    var p  = await rp.FindByIdAsync(id);
    p!.Email = "grace@example.com";
    await rp.UpdateAsync(p);
});

Fremdschlüssel & Reihenfolge

[Table("orders")]
public sealed class Order
{
    [PrimaryKey, AutoIncrement]
    [Column("id")]
    public long Id { get; set; }

    [Column("person_id", IsNullable = false)]
    [ForeignKey(typeof(Person), nameof(Person.Id), OnDelete = OnDeleteAction.Cascade)]
    public long PersonId { get; set; }

    [Column("total", IsNullable = false)]
    public decimal Total { get; set; }

    [Column("note", IsNullable = true, Length = 200)]
    public string? Note { get; set; }
}

Schema-Erzeugung in Reihenfolge (Principal → Dependent):

await SQLiteM.Orm.Pub.SQLiteMBootstrap.EnsureCreatedAsync(
    uow, builder, default,
    typeof(Person), typeof(Order));

Doku (DocFX)

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SQLiteM.Abstractions:

Package Downloads
SQLiteM.Orm

Leichtgewichtiges Micro-ORM für SQLite (C#)

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.3 381 11/17/2025
0.1.2 236 10/26/2025
0.1.1 238 10/21/2025
0.1.0 245 10/21/2025