Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 } C# and Visual Studio 2008 }
Agenda Talk about Object Relational Impedance Mismatch, and why it matters Go on a brief overview of Object Relational Mapping & NHibernate Demo NHibernate and LINQ for NHibernate, and how it deals with data in.NET applications
Object Relational Impedance Mismatch RDBMS are optimized for data, OOP was optimized for behavior RDBMS use tables and joins, OOP uses objects, inheritance and composition No straightforward way to represent tables and columns as classes and attributes, and vice versa
The Vietnam of Computer Science “[Object relational impedance mismatch] represents a quagmire which starts well, gets more complicated as time passes, and before long entraps its users in a commitment that has no clear demarcation point, no clear win conditions, and no clear exit strategy.” - Ted Neward
Attempts to solve the Object Relational Impedance Mismatch in.NET ADO.NET – Typed Datasets LINQ to SQL Entity Framework LLBLGen Objectmapper.NET iBATIS.NET Subsonic Lightspeed NHibernate db4o
Object Relational Mapping Attempts to solve object relational impedance mismatch Data infrastructure is represented in separate files or as.NET attributes Main aim is to maintain POCOs (Plain Old CLR Objects)
Why should I care about POCOs? Loose coupling from data infrastructure Testability Ability to adhere to tenets of object oriented programming (as opposed to data- driven programming)
NHibernate Ported from Hibernate, a popular ORM in Java Open source Works with Microsoft SQL Server, Oracle, MySQL, etc. Uses XML to map objects to the database schema De facto standard for OR Mapping LINQ provides a new way to simplify NHibernate queries
Steps Download Nhibernate 2.0 Beta –More information on setting up Nhibernate for your application can be found on The NHibernate FAQ: Download NHContrib from Sourceforge using subversion – Create your solution, add a reference to the NHibernate.Linq project
LINQ for NHibernate Demo
LINQ for NHibernate Pros & Cons Strongly typed queries Eliminates need for string literals Intellisense support Still in alpha (not included in NHibernate 2.0 beta!) Still in alpha (not included in NHibernate 2.0 beta!) Hasn't covered more complex join scenarios (yet) Hasn't covered more complex join scenarios (yet)
References NHibernate: – NHContrib: – The NHibernate FAQ: – The Vietnam of Computer Science by Ted Neward –
Your speaker Blog Blog – Forums (username = LaTtEX) Forums (username = LaTtEX) – Twitter Twitter –
Cormant is hiring: Technical Leads and Senior Software Design Engineers You must be a strong developer ready to roll up your sleeves, but will also be responsible for Team Lead duties such as resource allocations, task estimates, and coordination with Quality Assurance. You must be a strong developer ready to roll up your sleeves, but will also be responsible for Team Lead duties such as resource allocations, task estimates, and coordination with Quality Assurance. You have a proven experience in providing technical and design solutions using Object Oriented Analysis and Design (OOAD). You have a proven experience in providing technical and design solutions using Object Oriented Analysis and Design (OOAD). You have a strong opinion on whether to favor composition over inheritance. You have a strong opinion on whether to favor composition over inheritance. You prefer to think through a problem rather than programming like mad. You prefer to think through a problem rather than programming like mad. “Refactor mercilessly” is not just a tee shirt slogan. “Refactor mercilessly” is not just a tee shirt slogan. You get satisfaction in doing a job right. You get satisfaction in doing a job right. You have proven experience in C#, NHibernate, Agile development methodologies (Test-driven development, Continuous Integration). You have proven experience in C#, NHibernate, Agile development methodologies (Test-driven development, Continuous Integration). your resume to your resume to
© 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.