SlideShare a Scribd company logo
Welcome Everyone!
Today's Topic
Object Relational Mapping
with Dapper (a micro ORM)
Road map
Application Architecture
↓
Databases
↓
ORM
↓
Dapper
Web App Architecture
Databases
(A quick overview)
Types of Databases
● Relational Database Management Systems (RDBMS)
● NoSQL and Object-Oriented (OODBMS)
RDBMS
Data Storage
– Rows and columns (Tabular Form)
Features
– Simple, better performance of managing data
– Mathematical foundation (Relational Algebra)
– Flattening and scattering -> unnatural
– Limitations: everything doesn't fit in relations
– Conversion needed (impedance mismatch)
NoSQL and OODBMS
Data Storage
– Object Form
Features
– No conversion needed (no impedance mismatch)
– Relationships are directly represented, rather than requiring
join tables/operations
– Better at modeling complex objects
– No mathematical foundation
– Don’t have maturity of RDBMS yet
Incompatible Type Systems
● During systems collaboration if systems found having
different type systems, they are said to be Incompatible
Type Systems and can't interact with each other without an
interface. E.g. OO Applications and RDBMS.
● A mechanism/solution is needed to overcome this
incompatibility gap for proper collaboration.
Solution for Incompatibility?
What is an ORM?
● It is a programming technique for converting data between
incompatible type systems in object-oriented programming
languages.
Why to use ORM?
● Many popular database products such as structured query
language database management systems (SQL DBMS) can
only store and manipulate scalar values such as integers
and strings organized within tables. The programmer must
convert the object values for storage in the database into
groups of simpler values (and convert them back upon
retrieval).
● For most of the data-access code that developers usually
need to write, it eliminates.
Problems with ORM
● Object-Relational Impedance Mismatch (paradigm
mismatch) is a way of saying that object models and
relational models do not work very well together. Loading
and storing graphs of objects using a tabular relational
database exposes 5 mismatch problems.
– Granularity
– Subtypes (inheritance)
– Identity
– Associations
– Data navigation
Types of ORM
● Entity-based relational mapping
– Change tracking, Lazy-loading, Eager fetching, Cascades, Identity map, Unit of work
tracking
● Result-set-based relational mapping
– Map straight to DTOs and skip needing to configure mapping
● DML-based relational mapping (micro ORMs)
– SQL is brought to the forefront, mapping on the fly and only need a connection
● Bulk loading tools
– Limited to INSERT and SELECT
Boring???
Dapper
(A micro ORM)
Why Dapper ?
● Simple object mapper for .Net
● Performance is a key feature
Why Dapper is Simple/ Lightweight?
● Many feature that ORMs ship with are stripped out, there is
no identity map, there are no helpers for update/select
and so on.
● Dapper does not manage your connection's life cycle, it
assumes the connection it gets is open AND has no existing
data readers enumerating.
Dapper Performance Measures?
Dapper in Action
Dapper in Action
● Dapper is a “single file” (SqlMapper.cs) that will extend
your IDbConnection interface.
● It provides 3 helpers:
– Execute a query and map the results to a strongly typed
List
– Execute a query and map it to a list of dynamic objects
– Execute a Command that returns no results
(1) Query with Strongly Typed Result
(2) Query with Dynamic Object Result
(3) Command with No Result
Execute a Command multiple times
Execute a Stored Procedure
Multiple Results in Single Query
Limitations of Dapper?
● Many feature that ORMs ship with are stripped out, there is
no identity map, there are no helpers for update/select and
so on.
● Dapper does not manage your connection's life cycle, it
assumes the connection it gets is open.
Final words on Dapper
(Finally towards ending!)
Configurations (Most hectic activity)?
Surprisingly!!! No configuration needed in project, just add
reference to the library and you are done.
– Reasons
● It uses existing db connection (extends IDbConnection).
● It just does object mapping, nothing else as mentioned in
features.
Applications
● Stack Overflow
● Helpdesk
● And many more
Dapper and DB providers
● Dapper has no DB specific implementation details, it works
across all .Net ADO providers including sqlite, sqlce,
firebird, oracle, MySQL, PostgreSQL and SQL Server.
Conclusion
● Simple and lightweight to implement / use.
● Provide enough helpers/ support to do ORM activities.
● Doesn't suppress developers SQL skills.
Recommendation (Hybrid Approach)
● Dapper was written with speed (not features) as a priority.
● Using Dapper felt like writing SQL, which majority of developers
avoid when possible.
● For Entity Framework slowness issue, replace queries with
either a view or a stored procedure, depending on the
situation.
● Hybrid approach: Use EF for normal cases due to ease and use
Dapper where performance boost in needed.
References
● http://en.wikipedia.org/wiki/Object-relational_mapping
● http://hibernate.org/orm/what-is-an-orm/
● https://github.com/StackExchange/dapper-dot-net
● https://www.cl.cam.ac.uk/~fms27/db/tr-98-2.pdf
● http://searchcio.techtarget.com/opinion/Relational-databases-are-far-from-dead-just-ask-Facebook
● https://www.quora.com/What-is-LinkedIn-s-database-architecture-like
● http://www.infoq.com/news/2010/08/linkedin-data-infrastructure
● http://blog.dontpaniclabs.com/post/2014/05/01/Speed-Comparison-Dapper-vs-Entity-Framework
● http://lostechies.com/jimmybogard/2012/07/20/choosing-an-orm-strategy/
● http://forums.asp.net/t/1792276.aspx?which+is+better+to+use+dapper+or+entity

More Related Content

What's hot (14)

PPTX
Domain oriented development
rajmundr
 
PPTX
Day 7 - Make it Fast
Barry Jones
 
PPTX
JavaScript : A trending scripting language
AbhayDhupar
 
PPTX
ASP.NET MVC and Entity Framework 4
James Johnson
 
PPSX
Ebooks without Vendors: Using Open Source Software to Create and Share Meanin...
Matt Weaver
 
PDF
Keeping the fun in functional w/ Apache Spark @ Scala Days NYC
Holden Karau
 
PPTX
MVC and Entity Framework 4
James Johnson
 
PPTX
Query-time Nonparametric Regression with Temporally Bounded Models - Patrick ...
Lucidworks
 
PPTX
Web Ninja
Alfi Rizka
 
PDF
Your First Scala Web Application using Play 2.1
Matthew Barlocker
 
PPTX
Building Apis in Scala with Playframework2
Manish Pandit
 
PPT
Drupal: an Overview
Matt Weaver
 
PPTX
Trends in programming languages
Antya Dev
 
PDF
The JSON architecture
Constantin Dumitrescu
 
Domain oriented development
rajmundr
 
Day 7 - Make it Fast
Barry Jones
 
JavaScript : A trending scripting language
AbhayDhupar
 
ASP.NET MVC and Entity Framework 4
James Johnson
 
Ebooks without Vendors: Using Open Source Software to Create and Share Meanin...
Matt Weaver
 
Keeping the fun in functional w/ Apache Spark @ Scala Days NYC
Holden Karau
 
MVC and Entity Framework 4
James Johnson
 
Query-time Nonparametric Regression with Temporally Bounded Models - Patrick ...
Lucidworks
 
Web Ninja
Alfi Rizka
 
Your First Scala Web Application using Play 2.1
Matthew Barlocker
 
Building Apis in Scala with Playframework2
Manish Pandit
 
Drupal: an Overview
Matt Weaver
 
Trends in programming languages
Antya Dev
 
The JSON architecture
Constantin Dumitrescu
 

Viewers also liked (20)

PPTX
Dapper
Suresh Loganatha
 
PDF
Dapper & Dapper.SimpleCRUD
Blank Chen
 
PPTX
Dapper performance
Suresh Loganatha
 
PPTX
Dapper - Rise of the MicroORM
SquareHire
 
PPTX
Object relational and extended relational databases
Suhad Jihad
 
PPTX
Connection Resiliency and Command Interception in Entity Framework
Muhammad Umar
 
PPTX
Cloud monitoring功能簡介
Yi jhen Hong
 
PPTX
Building High Performance Websites - Session-1
Usama Nada
 
PPTX
Entity framework introduction sesion-1
Usama Nada
 
PPTX
.NET Database Toolkit
wlscaudill
 
PPTX
Dapper + QueryObject
Alexander Byndyu
 
PDF
Comparision
saurabhbagane
 
PPTX
Telerik Reporting for HTML 5 Apps
Muhammad Umar
 
PDF
NoSQL Databases - Lecture 12 - Introduction to Databases (1007156ANR)
Beat Signer
 
PPT
"Diffrence between RDBMS, OODBMS and ORDBMS"
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Ordbms
ramandeep brar
 
PPTX
Rdbms
rdbms
 
PDF
ITB2015 - Crash Course in Ionic + AngularJS
Ortus Solutions, Corp
 
PPT
Software Development Life Cycle (SDLC)
Compare Infobase Limited
 
PDF
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Beat Signer
 
Dapper & Dapper.SimpleCRUD
Blank Chen
 
Dapper performance
Suresh Loganatha
 
Dapper - Rise of the MicroORM
SquareHire
 
Object relational and extended relational databases
Suhad Jihad
 
Connection Resiliency and Command Interception in Entity Framework
Muhammad Umar
 
Cloud monitoring功能簡介
Yi jhen Hong
 
Building High Performance Websites - Session-1
Usama Nada
 
Entity framework introduction sesion-1
Usama Nada
 
.NET Database Toolkit
wlscaudill
 
Dapper + QueryObject
Alexander Byndyu
 
Comparision
saurabhbagane
 
Telerik Reporting for HTML 5 Apps
Muhammad Umar
 
NoSQL Databases - Lecture 12 - Introduction to Databases (1007156ANR)
Beat Signer
 
"Diffrence between RDBMS, OODBMS and ORDBMS"
baabtra.com - No. 1 supplier of quality freshers
 
Rdbms
rdbms
 
ITB2015 - Crash Course in Ionic + AngularJS
Ortus Solutions, Corp
 
Software Development Life Cycle (SDLC)
Compare Infobase Limited
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Beat Signer
 
Ad

Similar to Object Relational Mapping with Dapper (Micro ORM) (20)

PDF
L17 Data Source Layer
Ólafur Andri Ragnarsson
 
PDF
Secrets of Spark's success - Deenar Toraskar, Think Reactive
huguk
 
PPTX
ORM Methodology
Ahmed Gomaa
 
ODP
Introduction to SQL Alchemy - SyPy June 2013
Roger Barnes
 
PDF
In-Memory Computing - The Big Picture
Markus Kett
 
PDF
Some NoSQL
Malk Zameth
 
PPTX
20160524 ibm fast data meetup
shinolajla
 
PPTX
NoSQL - Not Only SQL
EasyData
 
PDF
Introduction to NoSQL
Dimitar Danailov
 
PPTX
Apache Spark for Beginners
Anirudh
 
PPT
Java Developers, make the database work for you (NLJUG JFall 2010)
Lucas Jellema
 
PPTX
Evolution of the DBA to Data Platform Administrator/Specialist
Tony Rogerson
 
ODP
Introduction to MongoDB
Knoldus Inc.
 
PDF
L15 Organising Domain Layer
Ólafur Andri Ragnarsson
 
PDF
NoSQL and CouchDB: the view from MOO
James Hollingworth
 
PDF
From ddd to DDD : My journey from data-driven development to Domain-Driven De...
Thibaud Desodt
 
PDF
Big Data processing with Apache Spark
Lucian Neghina
 
PDF
What is Distributed Computing, Why we use Apache Spark
Andy Petrella
 
PPTX
Intro to Big Data and NoSQL
Don Demcsak
 
PPTX
Learn about SPARK tool and it's componemts
siddharth30121
 
L17 Data Source Layer
Ólafur Andri Ragnarsson
 
Secrets of Spark's success - Deenar Toraskar, Think Reactive
huguk
 
ORM Methodology
Ahmed Gomaa
 
Introduction to SQL Alchemy - SyPy June 2013
Roger Barnes
 
In-Memory Computing - The Big Picture
Markus Kett
 
Some NoSQL
Malk Zameth
 
20160524 ibm fast data meetup
shinolajla
 
NoSQL - Not Only SQL
EasyData
 
Introduction to NoSQL
Dimitar Danailov
 
Apache Spark for Beginners
Anirudh
 
Java Developers, make the database work for you (NLJUG JFall 2010)
Lucas Jellema
 
Evolution of the DBA to Data Platform Administrator/Specialist
Tony Rogerson
 
Introduction to MongoDB
Knoldus Inc.
 
L15 Organising Domain Layer
Ólafur Andri Ragnarsson
 
NoSQL and CouchDB: the view from MOO
James Hollingworth
 
From ddd to DDD : My journey from data-driven development to Domain-Driven De...
Thibaud Desodt
 
Big Data processing with Apache Spark
Lucian Neghina
 
What is Distributed Computing, Why we use Apache Spark
Andy Petrella
 
Intro to Big Data and NoSQL
Don Demcsak
 
Learn about SPARK tool and it's componemts
siddharth30121
 
Ad

Recently uploaded (20)

PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
July Patch Tuesday
Ivanti
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
July Patch Tuesday
Ivanti
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Biography of Daniel Podor.pdf
Daniel Podor
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 

Object Relational Mapping with Dapper (Micro ORM)

  • 2. Today's Topic Object Relational Mapping with Dapper (a micro ORM)
  • 6. Types of Databases ● Relational Database Management Systems (RDBMS) ● NoSQL and Object-Oriented (OODBMS)
  • 7. RDBMS Data Storage – Rows and columns (Tabular Form) Features – Simple, better performance of managing data – Mathematical foundation (Relational Algebra) – Flattening and scattering -> unnatural – Limitations: everything doesn't fit in relations – Conversion needed (impedance mismatch)
  • 8. NoSQL and OODBMS Data Storage – Object Form Features – No conversion needed (no impedance mismatch) – Relationships are directly represented, rather than requiring join tables/operations – Better at modeling complex objects – No mathematical foundation – Don’t have maturity of RDBMS yet
  • 9. Incompatible Type Systems ● During systems collaboration if systems found having different type systems, they are said to be Incompatible Type Systems and can't interact with each other without an interface. E.g. OO Applications and RDBMS. ● A mechanism/solution is needed to overcome this incompatibility gap for proper collaboration.
  • 11. What is an ORM? ● It is a programming technique for converting data between incompatible type systems in object-oriented programming languages.
  • 12. Why to use ORM? ● Many popular database products such as structured query language database management systems (SQL DBMS) can only store and manipulate scalar values such as integers and strings organized within tables. The programmer must convert the object values for storage in the database into groups of simpler values (and convert them back upon retrieval). ● For most of the data-access code that developers usually need to write, it eliminates.
  • 13. Problems with ORM ● Object-Relational Impedance Mismatch (paradigm mismatch) is a way of saying that object models and relational models do not work very well together. Loading and storing graphs of objects using a tabular relational database exposes 5 mismatch problems. – Granularity – Subtypes (inheritance) – Identity – Associations – Data navigation
  • 14. Types of ORM ● Entity-based relational mapping – Change tracking, Lazy-loading, Eager fetching, Cascades, Identity map, Unit of work tracking ● Result-set-based relational mapping – Map straight to DTOs and skip needing to configure mapping ● DML-based relational mapping (micro ORMs) – SQL is brought to the forefront, mapping on the fly and only need a connection ● Bulk loading tools – Limited to INSERT and SELECT
  • 17. Why Dapper ? ● Simple object mapper for .Net ● Performance is a key feature
  • 18. Why Dapper is Simple/ Lightweight? ● Many feature that ORMs ship with are stripped out, there is no identity map, there are no helpers for update/select and so on. ● Dapper does not manage your connection's life cycle, it assumes the connection it gets is open AND has no existing data readers enumerating.
  • 21. Dapper in Action ● Dapper is a “single file” (SqlMapper.cs) that will extend your IDbConnection interface. ● It provides 3 helpers: – Execute a query and map the results to a strongly typed List – Execute a query and map it to a list of dynamic objects – Execute a Command that returns no results
  • 22. (1) Query with Strongly Typed Result
  • 23. (2) Query with Dynamic Object Result
  • 24. (3) Command with No Result
  • 25. Execute a Command multiple times
  • 26. Execute a Stored Procedure
  • 27. Multiple Results in Single Query
  • 28. Limitations of Dapper? ● Many feature that ORMs ship with are stripped out, there is no identity map, there are no helpers for update/select and so on. ● Dapper does not manage your connection's life cycle, it assumes the connection it gets is open.
  • 29. Final words on Dapper (Finally towards ending!)
  • 30. Configurations (Most hectic activity)? Surprisingly!!! No configuration needed in project, just add reference to the library and you are done. – Reasons ● It uses existing db connection (extends IDbConnection). ● It just does object mapping, nothing else as mentioned in features.
  • 31. Applications ● Stack Overflow ● Helpdesk ● And many more
  • 32. Dapper and DB providers ● Dapper has no DB specific implementation details, it works across all .Net ADO providers including sqlite, sqlce, firebird, oracle, MySQL, PostgreSQL and SQL Server.
  • 33. Conclusion ● Simple and lightweight to implement / use. ● Provide enough helpers/ support to do ORM activities. ● Doesn't suppress developers SQL skills.
  • 34. Recommendation (Hybrid Approach) ● Dapper was written with speed (not features) as a priority. ● Using Dapper felt like writing SQL, which majority of developers avoid when possible. ● For Entity Framework slowness issue, replace queries with either a view or a stored procedure, depending on the situation. ● Hybrid approach: Use EF for normal cases due to ease and use Dapper where performance boost in needed.
  • 35. References ● http://en.wikipedia.org/wiki/Object-relational_mapping ● http://hibernate.org/orm/what-is-an-orm/ ● https://github.com/StackExchange/dapper-dot-net ● https://www.cl.cam.ac.uk/~fms27/db/tr-98-2.pdf ● http://searchcio.techtarget.com/opinion/Relational-databases-are-far-from-dead-just-ask-Facebook ● https://www.quora.com/What-is-LinkedIn-s-database-architecture-like ● http://www.infoq.com/news/2010/08/linkedin-data-infrastructure ● http://blog.dontpaniclabs.com/post/2014/05/01/Speed-Comparison-Dapper-vs-Entity-Framework ● http://lostechies.com/jimmybogard/2012/07/20/choosing-an-orm-strategy/ ● http://forums.asp.net/t/1792276.aspx?which+is+better+to+use+dapper+or+entity