Skip to content
This repository was archived by the owner on Nov 16, 2024. It is now read-only.

sextondjc/Drapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build status Build status

Nuget status

Drapper

A data access / object composition library built on top of Dapper

Ever just wanted to execute a bit of SQL without jumping through the hoops imposed by other frameworks? Are you annoyed by the quirks of the monolithic ORM's? Tired of the limitations their design impose on your code? Tired of fighting the framework?

Then Drapper is for you. Drapper deliberately stays out of your way allowing you the choice of how to build your application your way.

You provide Drapper with the SQL to be executed. There is no auto-generated SQL. You will know the needs of your application better than any auto-generated SQL provider. That said, if you really do want auto-generated SQL you can plug this into Drapper by implementing an ICommandReader that will return a CommandSetting for you.

Quick Look

The heart of Drapper is the IDbCommander. It's an interface which exposes overloads of only 2 methods - Query and Execute. Query is used for data retrieval operations while Execute is used for persistence/data changing operations. Both methods come in Async flavours as well.

Query

IDbCommander _commander;

// retrieve all
_commander.Query<Country>()

// retrieve with parameters
_commander.Query<Country>(new { language = "English" });

// retrieve single
_commander.Query<Country>(new { code = "ZA" }).SingleOrDefault();

// map complex types
_commander.Query<Country, Currency, Country>(
    (country, currency) => 
    { 
        country.Currency = currency; 
        return country; 
    });

// map _really_ complex types
_commander.Query(Map.ReallyComplexMapping); // where Map.ComplexMapping is a Func<> with up to 16 inputs!

Execute

// all persistence operations are transactional. 
// transactions spanning multiple instances are automatically
// escalated to DTC. 

// persist a complex type
_commander.Execute(country);

// persist an object graph. each Execute call
// can target a different database instance if 
// you need it to! 
_commander.Execute(() => 
    {
        _commander.Execute(country);
        _commander.Execute(country.Currency, method:"SaveCurrency");
        _commander.Execute(country.States, method:"SaveStates");
    });

Drapper allows you to build complex object graphs from your data with ease as well as persist objects in a consistent, predictable and reliable way.

Drapper was built on top of the Dapper Micro ORM and works across all the same providers supported by Dapper including SQLite, SQL CE, Firebird, Oracle, MySQL, PostgreSQL and SQL Server.

Drapper? This project started as a "wrapper for Dapper". The portmanteau kinda wrote itself.

Releases

No releases published

Packages

No packages published

Languages