Git Product home page Git Product logo

leettle.data's Introduction

LeettleDB

Introduction

LeettleDB is a C# ADO.NET wrapper library to provide simple and easy api for different types of database providers and useful method that maps fetched result to a POCO.

Example

  • Creating leettleDB object
var leettleDb = new LeettleDbBuilder()
    .WithConnectionType(typeof(System.Data.SQLite.SQLiteConnection))
    .WithConnectionString("Data Source=:memory:;Version=3;New=True;")
    .WithBindStrategy(new CamelObjectSnakeDbBindStrategy(':'))
    .Build();
  • Fetching and mapping to POCO List
using (var con = leettleDb.OpenConnection())
{
    // codes disposing resource doesn't need.
    List<Author> authors = con.NewDataset("select * from Author where name like :name")
        .SetParam("name", "%phen%")
        .OpenAndFetchList<Author>();
}
  • Basic raw API fetching data
using (var con = leettleDb.OpenConnection())
{
    con.NewDataset("select * from Author where name like :name")
        .SetParam("name", "%phen%")
        .Open(dr =>
    {
        while (dr.Next())
        {
            var authorId = dr.GetInt("id");
            var authorName = dr.GetString("name");
        }
    });
}
  • Transaction
using (var con = leettleDb.OpenConnection())
{
    con.RunInTransaction(() =>
    {
        con.NewCommand("insert into Author values (:id, :name)")
            .SetParam("id", 1)
            .SetParam("name", "dodo")
            .Execute();
        
        con.NewCommand("insert into AuthorBook values (:id, :title)")
            .SetParam("id", 1)
            .SetParam("title", "dodo's story")
            .Execute();
    });
}

Check out Getting Started page.

Performance Benchmarking Test

Method Mean Error StdDev Ratio RatioSD
Leettle.Data 54.55 ms 0.657 ms 0.549 ms 1.29 0.02
Oracle Managed Data Direct Access 42.42 ms 0.464 ms 0.387 ms 1.00 0.00
NHibernate 119.83 ms 1.898 ms 2.031 ms 2.83 0.05

Installation

  • install Leettle.Data package through the nuget.
  • install ado.net data provider that what you want. (following data providers were tested)
    • Oracle (Oracle.ManagedDataAccess)
    • MySql (Mysql.Data)
    • PostgreSQL (Npgsql)
    • SQLite (System.Data.SQLite.Core)
    • SQL Server (System.Data.SqlClient)

leettle.data's People

Contributors

parakago avatar

Watchers

 avatar

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.