Skip to content

Latest commit

 

History

History
130 lines (79 loc) · 5.44 KB

README.md

File metadata and controls

130 lines (79 loc) · 5.44 KB

Norm Micro-ORM

Database mapper for .NET Standard 2.1

build-test-publish

Features at a Glance

Modern and Fast

Simple

  • 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"

Trustworthy and Reliable

  • 350+ automated tests for SqlServer, PostgreSQL, SQLite, and MySql.

  • 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.

All Databases

  • Implemented as set of extensions - for System.Data.Common.DbConnection instances.

  • Works with all databases based on common DbConnection class, and that is pretty much all databases.

  • Native support for ARRAY database types for database providers that have ARRAY support (PostgreSQL).

Lightweight

  • 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.

Usage

Get it on Nuget

> dotnet add package Norm.net

Use in project

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...

Performances

Testing

350+ automated tests for SqlServer, PostgreSQL, SQLite and MySql.

build-test-publish

Local testing

  • 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

Currently supported platforms

  • .NET Standard 2.1

Support

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

Licence

Copyright (c) Vedran Bilopavlović - VB Consulting and VB Software 2020 This source code is licensed under the MIT license.