7
Dapper Rise of the MicroORM Rudy Lacovara [email protected] http://rlacovara.blogspot.com

Dapper - Rise of the MicroORM

Embed Size (px)

DESCRIPTION

Presentation slides on Dapper, the best way to do persistence on .Net without destroying the maintainability of your app.

Citation preview

Page 1: Dapper - Rise of the MicroORM

DapperRise of the MicroORM

Rudy [email protected]

http://rlacovara.blogspot.com

Page 2: Dapper - Rise of the MicroORM

What is Dapper?It’s a data access technology written by these guys

Sam Saffronhttp://samsaffron.com

Marc Gravellhttp://marcgravell.blogspot.com/

Page 3: Dapper - Rise of the MicroORM

What is Dapper?

To make this go faster:

Page 4: Dapper - Rise of the MicroORM

Dapper is a simple data mapper

1. You write a querystring myQuery= “SELECT * FROM AppUser”

2. You pick a return class AppUser

3. You get an open IDbConnection var con = (new SqlConnection()).Open()

4. Dapper executes your query and maps the results to an IEnumerable<T> var users = con.Query<AppUser>(query)

Page 5: Dapper - Rise of the MicroORM

The Dapper Philosophy

• Embrace TSQL

• Run it really fast

• Keep It Simple StupidDapper is a single file that contains extension methods for IDBConnection

• Convention over Configurationmap returned data to DTOs by matching field names to property names

Page 6: Dapper - Rise of the MicroORM

PerformancePerformance of SELECT mapping over 500 iterations - POCO serializationMethod Duration

Hand coded (using a SqlDataReader) 47ms

Dapper ExecuteMapperQuery<Post> 49ms

ServiceStack.OrmLite(QueryById) 50ms

PetaPoco 52ms

BLToolkit 80ms

SubSonic 107ms

NHibernate SQL 104ms

Linq 2 SQL ExecuteQuery 181ms

Entity framework ExecuteStoreQuery 631ms

Performance stats taken from http://code.google.com/p/dapper-dot-net

Page 7: Dapper - Rise of the MicroORM

DieselWorkers Architecture• Common – code

needed across multiple layers

• Core – contains both business logic and data access logic. Core is the only library that connects to a DB.

• All application layer code, like the webapps and the processor, is built on top of Core.

Com

mon

Web App (MVC 3)

Core

SqlServer Database

MongoDBDocument

store

Processor

Single Page JavaScript App (Knockout.js)