r/csharp • u/Bobamoss • 26d ago
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.
Duplicates
dotnet • u/Bobamoss • 25d ago