Skip to content
HilthonTTPublic

About

A small .NET ORM with injection-safe SQL, typed queries and CRUD for SQLite, PostgreSQL, SQL Server and MySQL.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

MicroORM logo: amber threads woven through light threads

MicroORM

SQL in, objects out.
A small, provider-agnostic ORM for .NET with injection-safe SQL, typed queries and zero ceremony.

CI Documentation MIT license


var db = new MicroDb(SqlDialect.PostgreSql, dataSource);

// Every {hole} becomes a parameter. Plain strings don't compile.
var recent = await db.QueryAsync<Order>($"SELECT * FROM orders WHERE placed_at > {since} AND status IN {statuses}");

// Typed queries translated to SQL, never silently run in memory.
var vips = await db.Table<Customer>().Where(c => c.Active && c.LifetimeSpend > 10_000).Take(20).ToListAsync();

await db.Table<Customer>().InsertAsync(customer);                   // customer.Id is now set
await db.Table<Customer>().UpsertAsync(customer, on: c => c.Email); // atomic insert-or-update
  • Injection-safe by type: query methods take Sql, an interpolated string handler, so values are always parameters.
  • Typed queries: filters, ordering, paging, projections, grouping, EXISTS subqueries, aggregates, unions, row locks and set-based updates. Unsupported queries throw instead of running in memory.
  • CRUD without SQL: generated keys, composite keys, batched inserts, partial updates, upserts and optimistic concurrency.
  • Query filters: soft delete and multi-tenancy, applied to every typed query of an entity.
  • Joins and result sets: split rows into objects, or read several result sets from one command.
  • Type handlers: value objects, strongly typed IDs, JSON columns and enums as text.
  • Sync and async: every API has both forms. Reads keep pace with Dapper.
  • No dependencies: bring your own ADO.NET provider for SQLite, PostgreSQL, SQL Server or MySQL.

Getting started

MicroORM targets .NET 10 and isn't published as a package. Reference the project and add your provider:

git clone https://github.com/HilthonTT/MicroORM.git
dotnet add reference MicroORM/src/MicroORM/MicroORM.csproj
dotnet add package Microsoft.Data.Sqlite   # or Npgsql, Microsoft.Data.SqlClient, MySqlConnector
using Microsoft.Data.Sqlite;
using MicroORM.Dialects;
using MicroORM.Sessions;

var db = new MicroDb(SqlDialect.Sqlite, () => new SqliteConnection("Data Source=app.db"));

var books = db.Table<Book>();
await books.InsertAsync(new Book { Title = "Piranesi", Pages = 272 });
var unread = await books.Where(b => !b.Finished).OrderBy(b => b.Title).ToListAsync();

public class Book
{
    public int Id { get; set; }          // "Id" is the key; integer keys are database-generated
    public string Title { get; set; } = "";
    public int Pages { get; set; }
    public bool Finished { get; set; }
}

Run the full example with dotnet run --project samples/MicroORM.Samples.QuickStart.

Documentation

Guides for mapping, querying, transactions, joins, type handlers, stored procedures and each database are on the documentation site.

Contributing

dotnet test MicroORM.slnx    # unit tests and SQLite; other databases: see CONTRIBUTING.md

Contributions are welcome. Read CONTRIBUTING.md and the Code of Conduct first, and report security issues as described in SECURITY.md.

License

MIT © 2026 Hilthon

About

A small .NET ORM with injection-safe SQL, typed queries and CRUD for SQLite, PostgreSQL, SQL Server and MySQL.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages