4. Dapper is a simple data mapper
1. You write a query
string 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)
5. The Dapper Philosophy
• Embrace TSQL
• Run it really fast
• Keep It Simple Stupid
Dapper is a single file that contains extension methods for
IDBConnection
• Convention over Configuration
map returned data to DTOs by matching field names to
property names
6. Performance
Performance of SELECT mapping over 500 iterations - POCO
serialization
Method 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
7. 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.
Common
Web App (MVC 3)
Core
SqlServer
Database
MongoDB
Document
store
Processor
Single Page JavaScript App
(Knockout.js)