ORM Tools and Techniques - NHibernate - by Amin Emami
-
Upload
amin-emami -
Category
Documents
-
view
145 -
download
1
description
Transcript of ORM Tools and Techniques - NHibernate - by Amin Emami
![Page 1: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/1.jpg)
Amin Emamiwww.aminemami.com
![Page 2: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/2.jpg)
• Introduction• Object Relational Mapping• Persistence Framework• Sample Code• Q&A
Amin Emami
![Page 3: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/3.jpg)
• Director of Information Technology• 10 Years of Enterprise Software
Development• Using Persistence Frameworks since
2001o EJB (Java): 2001o Hibernate (Java): 2004o NHibernate (.Net): 2005o Entity Framework: 2009
Amin Emami
![Page 4: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/4.jpg)
Amin Emami
Architectural View
![Page 5: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/5.jpg)
How do you map these classes to relational tables?
Amin Emami
![Page 6: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/6.jpg)
• Object-Oriented: Everything is an object• Objects vs. Tables: ODBMS?• OO features• Object Types vs. DB Types• CRUD to/from database• Objects vs. tabular data• Managed Code
Amin Emami
![Page 7: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/7.jpg)
• A technique to map the classes and the tables• Simplified rules
o Table per main objecto No FK, use object referenceo One-to-many relationso Association table for many-to-many relationso In a one-to-one relation, all the fields go to one
main tableo Inheritance mapping strategies
Tale per class hierarchy Table per concrete class
Amin Emami
![Page 8: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/8.jpg)
Amin Emami
![Page 9: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/9.jpg)
• Let’s take a look at the sample codeo Class Diagramo POCO classes
Amin Emami
![Page 10: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/10.jpg)
• ORM library, providing a framework foro Mapping an object-oriented domain model to
relational databaseo High level persistence object handling
functions
Amin Emami
![Page 11: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/11.jpg)
Some of .Net Persistence Frameworks:• NHibernate • Entity Framework• Gentle.NET• Wilson O/R • NPersist• Persistor.NET• iBATIS• Bamboo.Prevalence• etc
Amin Emami
![Page 12: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/12.jpg)
Amin Emami
![Page 13: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/13.jpg)
Amin Emami
![Page 14: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/14.jpg)
• Class Diagram• POCO classes• Mapping files• Configurations• Transactions
Amin Emami
![Page 15: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/15.jpg)
• Better object-oriented• Collection Mapping• Basic queries and object persistence is
handled by the framework• Object query language instead of SQL,
doing more complex queries• Lazy loading
Amin Emami
![Page 16: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/16.jpg)
• Database independency• Transaction management• Automatic primary key generation• Automatic dirty checking• Detached object• Concurrency• Caching
Amin Emami
![Page 17: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/17.jpg)
• Caching• Detached object• Concurrency• Interceptors• Batch processing• Attributes• Fluent Syntax• Database independency
Amin Emami
![Page 18: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/18.jpg)
• ORM Concept• Simple ORM Techniques• Persistence Frameworks• NHibernate Key Features
Amin Emami
![Page 19: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/19.jpg)
Amin Emami
![Page 20: ORM Tools and Techniques - NHibernate - by Amin Emami](https://reader033.fdocuments.in/reader033/viewer/2022051615/55259591550346a26e8b4990/html5/thumbnails/20.jpg)
• You are free:o to Share―to copy, distribute and transmit the worko to Remix―to adapt the work
• Under the following conditionso Attribution. You must attribute the work in the manner specified
by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
• Nothing in this license impairs or restricts the author’s moral rights.
• For more information see http://creativecommons.org/licenses/by/3.0/
Amin Emami