Skip to content

Orm that takes the best from Dapper and EF.Core

License

Notifications You must be signed in to change notification settings

AlexeyShirshov/nextorm

Repository files navigation

Next ORM

The goal is to be as fast as Dapper but get rid of writing sql code manually.
All sql code and parameters should be generated automatically, with intellisense, type checking and other c# features.
NextORM is not really an ORM, because abbreviation "Object" can be removed. There is no change tracking (as ineffective), the entity class is not required. There are many ways to map data from database to objects: declarative (via attributes), fluent api, directly in query.

Features

Examples

Select data via entity to map props and type to columns and table respectively

[SqlTable("simple_entity")]
public interface ISimpleEntity
{
    [Key]
    [Column("id")]
    int Id {get;set;}
}
//...
// load data into anonymous object
foreach(var row in await dataContext.SimpleEntity.Select(entity => new { entity.Id }).ToListAsync())
{
    _logger.LogInformation("Id = {id}", row.Id);
}

Select data without any entity, meta attributes, etc. Pure sql

foreach(var row in await dataContext.From("simple_entity").Select(tbl => new { Id = tbl.Int("id") }).ToListAsync())
{
    _logger.LogInformation("Id = {id}", row.Id);
}

Subquery with strong typings

var innerQuery = dataContext.From("simple_entity").Select(tbl => new { Id = tbl.Int("id") });
await foreach(var row in dataContext.From(innerQuery).Select(subQuery=>new { subQuery.Id }))
{
    _logger.LogInformation("Id = {id}", row.Id);
}
// generated code is 
// select id from (select id from simple_entity)

Benchmarks

Benchmark is running under the following conditions:

  • Nextorm is compiled buffered
  • Dapper is buffered
  • EF core is compiled buffered
  • All queries are async
  • Data provider is SQLite
  • Computer configuration: Intel(R) Core(TM) i5-9600KF CPU @ 3.70GHz, RAM 16Gb
  • .NET SDK 8.0.100
Method Nextorm Dapper EF core
Data fetch 41.08 μs 42.28 μs 57.95 us
Wide data fetch 10.060 ms 13.789 ms 12.858 ms
Where 4.002 ms 4.208 ms 5.442 ms
Simulate work 160.8 ms 213.2 ms 246.1 ms
Any 31.74 us 38.83 us 54.16 us
FirstOrDefault 337.4 us 432.2 us 586.9 us
SingleOrDefault 36.65 us 39.60 us 51.99 us

Summary

Place Nextorm Dapper EF core
First 7
Second 6 1
Third 1 6

About

Orm that takes the best from Dapper and EF.Core

Resources

License

Stars

Watchers

Forks

Packages

No packages published