Object Relational Mapping from A to Z

Object Relational
Mapping A to Z
Twitter: @greeleygeek
E-Mail: [email protected]
About Me
Over A Decade of
I.T. Experience
Web Developer,
DBA, DevOps, Mobile
Microsoft Cert.
in SQL Server
• What an Object Relational Mapper Is
• Why you might use an Object Relational Mapper
• Problems using Object Relational Mapper
• Solutions to common issues
• Popular Object Relational Mapper examples
• Debugging
• Final Tips
What Is It?
• Wikipedia: …”technique for converting data
between incompatible type systems in objectoriented programming languages. This creates, in
effect, a ‘virtual object database’ that can be used
from within the programming language”
• “Maps” set based data to objects useable by Object
Oriented languages.
What Is An ORM
What is An ORM?
© Universal Studios. All rights Reserved.
What Is An ORM?
• Database Management Systems: ~1960
• Object Oriented Programming: ~50s/60s
• One of the first ORMs was TopLink for SmallTalk in
Popular Flavors
What Is An ORM?
Object Impedance Mismatch
Wikipedia defines this as: “…conceptual and technical
difficulties that are often encountered when
a relational database management system (RDBMS)
is being used by a program written in an objectoriented programming language or style; particularly
when objects or class definitions are mapped in a
straightforward way to database tables or relational
The “ORM problem”
• Abandon the Object Model altogether returning to
traditional methods
• Use a storage method that is object oriented itself
(OODBMS, NoSQL possibly)
• Hand-crafting each Mapping
• Mix of ORM and SQL
• Integrate datasets into language itself (think LINQ)
• Build solution on relational concepts (blocks of
The Good News
Taking A Peek
NHibernate Demo
NHibernate Demo
NHibernate Demo
NHibernate Demo
NHibernate Demo
NHibernate Demo
Nhibernate Demo
NHibernate Demo
Taking A Peek
Entity Framework
Entity Framework
Entity Framework
Entity Framework
Entity Framework
Entity Framework
Entity Framework
Entity Framework
Entity Framework
Entity Framework
Micro ORM
• Slimmed down ORMs
• What they lack in features they make up for in
• Popular flavors are PetaPoco and Dapper
Massive Demo
Debugging An ORM Demo
ORM Pros
• Simpler for developers
• Supports many database platforms
• Supports many different languages
• The impedance mismatch is handled for us
• Developer can focus on the code, not the database
ORM Cons
• Can be cumbersome to set up (NHibernate)
• Joins and complex queries can be difficult
• Hard to read performance metrics
• Another layer between the database and the
Final Thoughts
• ORMs continue to advance
• Work for most solutions
• Consider stored procedures or views for finer
Twitter: @greeleygeek
E-Mail: [email protected]
Code Links
• NHibernate Demo Source Code:
• Entity Framework Demo Source Code:
• Massive Micro ORM Demo Source Code:
• Slides posted at: http://zero1design.com

similar documents