Database mapper for .NET Standard 2.1
-
Maps to basic, built-in types (int, string, etc),
named tuples
,records
orplain old classes
to map the results from your databases. In fact, it will map to pretty much anything. -
Uses async enumerables and powerful
asynchronous database streaming
-
Very fast mapping.
performances indistinguishable from the raw data reader
.
- You don't have to declare a new class every time:
var result = connection.Read<(int i, string bar)>("select 1 as id, 'foo' as bar").First();
Console.WriteLine(result.i); // outputs 1
Console.WriteLine(result.bar); // outputs "foo"
-
350+ automated tests for
SqlServer
,PostgreSQL
,SQLite
, andMySql
. -
Source links
are included in the package. That means that you can [Step Into] the source code when debugging to see exactly what it does.
-
Implemented as set of extensions - for
System.Data.Common.DbConnection
instances. -
Works with all databases based on
common DbConnection
class, and that is pretty muchall databases.
-
Native support for
ARRAY
database types for database providers that haveARRAY
support (PostgreSQL).
-
Only three main extensions -
Execute
,Read
and Multiple. That's all it takes. There is no learning curve at all. -
No need for extra configuration or any special attributes.
-
Small, and absolutely
no dependencies whatsoever.
-
All public methods were thoroughly documented in documentation comments that are
available to IntelliSense
and shipped with the package. -
User friendly manual available.
> dotnet add package Norm.net
using Norm;
using System.Linq;
// Start using database connection extensions:
// Map results to record
var records = connection.Read<MyRecord>("select id, foo, bar from table");
// Map results to class
var classes = connection.Read<MyClass>("select id, foo, bar from table");
// Map single values to a tuple and deconstruct to three variables
var (id, foo, bar) = connection.Read<int, string, string>("select id, foo, bar from table").Single();
// Map to a named tuple (id, foo, bar):
var tuple = connection.Read<(int id, string foo, string bar)>("select id, foo, bar from table").Single();
// Asynchronously stream values directly from database
await foreach(var (id, foo, bar) in connection.ReadAsync<int, string, string>("select id, foo, bar from table"))
{
//...
}
// etc...
-
See detailed performance benchmarks compared to Dapper at performance tests page.
-
To run beckmark console manually, configure local testing for PostgreSQL unit tests project first. See instructions for local testing bellow.
350+ automated tests for SqlServer
, PostgreSQL
, SQLite
and MySql
.
- Under each test project there is a
testsettings.json
. - Copy this file and rename it to
testsettings.local.json
. It will be ignored by git. - Set the key
Default
to the value of your actual, local connection string. - The key
TestDatabase
contains the name of the test database, which is created and dropped on each testing session, so be careful about that. - Run
dotnet test
- .NET Standard 2.1
This is open-source software developed and maintained freely without any compensation whatsoever.
If you find it useful please consider rewarding me on my effort by buying me a beer🍻 or buying me a pizza🍕
Or if you prefer bitcoin: bitcoincash:qp93skpzyxtvw3l3lqqy7egwv8zrszn3wcfygeg0mv
Copyright (c) Vedran Bilopavlović - VB Consulting and VB Software 2020 This source code is licensed under the MIT license.