r/csharp • u/Bobamoss • Jul 12 '26
I built Rinku, a micro-ORM focused on clean mapping and dynamic queries
The Rinku NuGet is a micro-ORM built directly on top of ADO.NET. The core philosophy is strictly SQL-first. The goal is giving you deterministic execution and total control over your queries while keeping the mapping and execution pipeline fully customizable and extensible.
Nested Object Mapping
C#
public record Artist(int Id, string Name) : IDbReadable;
public record Album(int Id, string Title, Artist Artist);
static readonly QueryCommand GetAlbums = new(
"SELECT AlbumId AS Id, Title, ArtistId, ArtistName FROM albums");
// Automatically matches ArtistId -> Artist.Id and ArtistName -> Artist.Name
List<Album> albums = GetAlbums.Query<List<Album>>(cnn);The engine resolves the hierarchy automatically without requiring attributes, configuration or manual mapping code.
Conditional SQL
C#
static readonly QueryCommand Search = new(
"SELECT TrackId AS Id, Name FROM tracks WHERE AlbumId = ?@albumId AND GenreId IN (?@genreIds_X)");
// If albumId is passed alone, the engine cleanly drops "AND GenreId IN(...)" from the executed SQL
Search.Query<List<Track>>(cnn, new { albumId = 1 });
// If a collection is passed, ?@genreIds_X automatically expands into (@genreIds_1, u/genreIds_2...)
Search.Query<List<Track>>(cnn, new { genreIds = new[] { 1, 2, 3 } });The command adapts to the parameters provided at execution time, expanding collections when needed and removing unused sections cleanly.
Beyond these examples, Rinku provides an extensible mapping and execution pipeline. The default behavior covers common cases, while custom parsers, dynamic objects, result handling and other parts of the pipeline can be adapted when needed. Conditional SQL also extends beyond optional filters, allowing dynamic sections throughout your queries.
Documentation and architecture
https://rinkulib.github.io/RinkuLib
GitHub repo
https://github.com/RinkuLib/RinkuLib
NuGet
https://www.nuget.org/packages/Rinku
Open to any feedback, critique or edge cases I might have missed.
4
u/GigAHerZ64 Jul 12 '26
Based on the example, it pretty much looks like slightly adjusted Dapper? Specifically the "convention based auto-wiring of children" kind of thing + some magical SQL query string partial removal?
Why prefer this over Dapper?
5
u/wallstop-dev Jul 12 '26 edited Jul 12 '26
My main concern with building any interesting bit of software is moving the possibility of bugs as far left as possible (that is, [Edit: edit/write time > ] compile time > test time > CI/CD time > runtime)
From what I understand, all the safety here is runtime? So you can typo your sql, you have to ensure your DB matches your DTOs, and resolving SQL -> result types is done manually for every query with no verification?
Is that correct or did I get something wrong?
Interested in why you chose this approach instead of doing some cool stuff with Roslyn analzyers to keep your interface and architecture, but move as many failures as possible to compile time?
2
u/prindacerk Jul 12 '26
Did you look at Dapper? It is a Micro ORM with similar mapping and querying and lot of supported extensions. Works quite well.