Git Product home page Git Product logo

ltquery's Introduction

LtQuery

Build status

LtQuery is a ORM focus on Easy-to-use and Performance.

LtQuery does not accept the input of SQL which is a string. Instead, call giving a diverty, tiny query object.

var blogQuery = Lt.Query<Blog>().Where(_ => _.Id == Lt.Arg<int>());
var blog = connection.QuerySingle(blogQuery, new { Id = blogId });

var postsQuery = blogQuery.To<Post>(_ => _.BlogId);
var posts = connection.Query(postsQuery, new{ Id = blogId });

Benchmark

'benchmarks/OrmPerformanceTests' result.
May be, wrong the settings. I don't think it's so fast.

Measurement environment

  • Windows
  • SQL Server 2019 Express on local.
  • LtQuery 0.1.0, Dapper 2.0.78, EFCore 5.0.5

SelectOne from Single table

Method Mean Error StdDev Median Gen 0 Gen 1 Gen 2 Allocated
LtQuery 97.09 μs 1.926 μs 5.206 μs 94.22 μs 0.4883 - - 2.21 KB
Dapper 139.58 μs 2.727 μs 3.911 μs 139.39 μs 0.9766 - - 4.37 KB
EFCore 190.78 μs 1.087 μs 1.017 μs 190.50 μs 2.6855 - - 11.3 KB

SelectAll(10,000) from Single table

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
LtQuery 7.050 ms 0.0691 ms 0.0679 ms 515.6250 - - 2.06 MB
Dapper 10.717 ms 0.1404 ms 0.1314 ms 390.6250 156.2500 62.5000 2.31 MB
EFCore 11.375 ms 0.0497 ms 0.0415 ms 796.8750 281.2500 171.8750 4.69 MB

Performance-aware code

In LtQuery, when the user holds the query object, the optimized process is executed when the second time Later.

// hold query object
private Query<Blog> _query;

public Blog Find(int id)
{
  if(_query == null)
    _query = Lt.Query<Blog>().Where(_ => _.Id == Lt.Arg<int>()).ToImmutable();
  return _connection.QuerySingle(_query, new{ Id = id });
}

Query-Object and Method Responsibility Segregation

In LtQuery, Query-Object may differ from the general concept.
Query-Object represents the "Region" of target data.
That is, The count function in SQL is not included in Query-Object.

LtQuery

Policy

Aiming for the best ORM for DDD which compromises that eliminates infrastructure dependence but relies on Lazy-Loading.

ltquery's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.