Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate {...

16

Transcript of Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate {...

Page 1: Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 }
Page 2: Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 }

Jacinto Limjap, Jr.Senior Software Design Engineer, Cormant

Technologies Inc.

LINQ for NHibernateLINQ for NHibernate { { Easy OR Mapping with Easy OR Mapping with C# and Visual Studio C# and Visual Studio

20082008 }}

Page 3: Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 }

AgendaAgenda

Talk about Object Talk about Object Relational Impedance Relational Impedance Mismatch, and why it Mismatch, and why it mattersmatters

Go on a brief overview of Go on a brief overview of Object Relational Mapping Object Relational Mapping & NHibernate& NHibernate

Demo NHibernate and Demo NHibernate and LINQ for NHibernate, and LINQ for NHibernate, and how it deals with data how it deals with data in .NET applicationsin .NET applications

Page 4: Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 }

Object Relational Impedance Object Relational Impedance MismatchMismatch

RDBMS are optimized for RDBMS are optimized for data, OOP was data, OOP was optimized for behavioroptimized for behavior

RDBMS use tables and RDBMS use tables and joins, OOP uses objects, joins, OOP uses objects, inheritance and inheritance and compositioncomposition

No straightforward way No straightforward way to represent tables and to represent tables and columns as classes and columns as classes and attributes, and vice attributes, and vice versaversa

Page 5: Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 }

The Vietnam of Computer ScienceThe Vietnam of Computer Science

““[Object relational impedance mismatch] represents a quagmire which [Object relational impedance mismatch] represents a quagmire which starts well, gets more complicated as time passes, and before long starts well, gets more complicated as time passes, and before long entraps its users in a commitment that has no clear demarcation entraps its users in a commitment that has no clear demarcation point, no clear win conditions, and no clear exit strategy.”point, no clear win conditions, and no clear exit strategy.”

- Ted Neward- Ted Neward

Page 6: Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 }

Attempts to solve the Object Attempts to solve the Object Relational Impedance Mismatch Relational Impedance Mismatch in .NETin .NET ADO.NET – Typed ADO.NET – Typed

DatasetsDatasets

LINQ to SQLLINQ to SQL

Entity FrameworkEntity Framework

LLBLGenLLBLGen

Objectmapper.NETObjectmapper.NET

iBATIS.NETiBATIS.NET

SubsonicSubsonic

LightspeedLightspeed

NHibernateNHibernate

db4odb4o

Page 7: Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 }

Object Relational MappingObject Relational Mapping

Attempts to solve Attempts to solve object relational object relational impedance mismatchimpedance mismatch

Data infrastructure is Data infrastructure is represented in separate represented in separate files or as .NET files or as .NET attributesattributes

Main aim is to maintain Main aim is to maintain POCOs (Plain Old CLR POCOs (Plain Old CLR Objects)Objects)

Page 8: Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 }

Why should I care about POCOs?Why should I care about POCOs?

Loose coupling from Loose coupling from data infrastructuredata infrastructure

TestabilityTestability Ability to adhere to Ability to adhere to

tenets of object tenets of object oriented oriented programming (as programming (as opposed to data-opposed to data-driven driven programming)programming)

Page 9: Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 }

NHibernateNHibernate

Ported from Hibernate, a Ported from Hibernate, a popular ORM in Javapopular ORM in Java

Open sourceOpen source

Works with Microsoft SQL Works with Microsoft SQL Server, Oracle, MySQL, etc.Server, Oracle, MySQL, etc.

Uses XML to map objects Uses XML to map objects to the database schemato the database schema

De facto standard for OR De facto standard for OR MappingMapping

LINQ provides a new way LINQ provides a new way to simplify NHibernate to simplify NHibernate queriesqueries

Page 10: Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 }

StepsSteps

Download Nhibernate 2.0 Beta -- Download Nhibernate 2.0 Beta -- http://nhibernate.orghttp://nhibernate.org– More information on setting up Nhibernate for your More information on setting up Nhibernate for your

application can be found on The NHibernate FAQ: application can be found on The NHibernate FAQ: http://blog.hibernatingrhinos.com/nhibernatehttp://blog.hibernatingrhinos.com/nhibernate

Download NHContrib from Sourceforge using Download NHContrib from Sourceforge using subversionsubversion– http://sourceforge.com/nhcontribhttp://sourceforge.com/nhcontrib

Create your solution, add a reference to the Create your solution, add a reference to the NHibernate.Linq projectNHibernate.Linq project

Page 11: Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 }

LINQ for NHibernate DemoLINQ for NHibernate Demo

Page 12: Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 }

LINQ for NHibernate Pros & ConsLINQ for NHibernate Pros & Cons

Strongly typed Strongly typed queriesqueries

Eliminates need for Eliminates need for string literalsstring literals

Intellisense supportIntellisense support

Still in alpha (not Still in alpha (not included in included in NHibernate 2.0 NHibernate 2.0 betabeta!)!)

Hasn't covered more Hasn't covered more complex join complex join scenarios (yet)scenarios (yet)

Page 13: Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 }

ReferencesReferences

NHibernateNHibernate::– http://nhibernate.orghttp://nhibernate.org

NHContrib: NHContrib: – http://sourceforge.net/projects/nhcontribhttp://sourceforge.net/projects/nhcontrib

The NHibernate FAQ:The NHibernate FAQ: – http://blogs.hibernatingrhinos.com/nhibernatehttp://blogs.hibernatingrhinos.com/nhibernate

The Vietnam of Computer Science by Ted NewardThe Vietnam of Computer Science by Ted Neward– http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Scienchttp://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Science.aspxe.aspx

Page 14: Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 }

Your speakerYour speaker

BlogBlog– http://dotnet.kapenilattex.comhttp://dotnet.kapenilattex.com

Forums (username = LaTtEX)Forums (username = LaTtEX)– http://msforums.ph/forumshttp://msforums.ph/forums

EmailEmail– [email protected]@gmail.com

TwitterTwitter– http://twitter.com/LaTtEXhttp://twitter.com/LaTtEX

Page 15: Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 }

Cormant is hiring: Technical Leads Cormant is hiring: Technical Leads and Senior Software Design and Senior Software Design EngineersEngineers

You must be a strong developer ready to roll up your sleeves, but You must be a strong developer ready to roll up your sleeves, but will also be responsible for Team Lead duties such as resource will also be responsible for Team Lead duties such as resource allocations, task estimates, and coordination with Quality allocations, task estimates, and coordination with Quality Assurance.Assurance.

You have a proven experience in providing technical and design You have a proven experience in providing technical and design solutions using Object Oriented Analysis and Design (OOAD).solutions using Object Oriented Analysis and Design (OOAD).

You have a strong opinion on whether to favor composition over You have a strong opinion on whether to favor composition over inheritance.inheritance.

You prefer to think through a problem rather than programming You prefer to think through a problem rather than programming like mad.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 You have proven experience in C#, NHibernate, Agile development

methodologies (Test-driven development, Continuous Integration).methodologies (Test-driven development, Continuous Integration). Email your resume to [email protected] your resume to [email protected]

Page 16: Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 }

© 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.© 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 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. 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.MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.