Upload
squarehire
View
591
Download
0
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
What is Dapper?It’s a data access technology written by these guys
Sam Saffronhttp://samsaffron.com
Marc Gravellhttp://marcgravell.blogspot.com/
What is Dapper?
To make this go faster:
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)
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
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
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)