Probably most of you are aware of LINQ and also have done some kind of work using LINQ to SQL which is the ORM product from Microsoft for its .Net platform (don't forget about LINQ to Entities, which is the Enterprise version of LINQ to SQL).
Well, let me tell you, if you don't already know, that exists an Open Source project which has some years out there, this project is NHibernate which is a port from the java version Hibernate, NHibernate is a powerful fully tested ORM tool that has proved over the years to be a great alternative to handle the data management in your applications. It has a learning curve that may scare you, but after a few days using it you'll never go back to the old ADO .Net API.
For further reading, you can check this post from Ayende which I'm sure is going to convince you to get involve and start using NHibernate in your applications.
If you haven't used NHibernate before, well, I recommend you to stop to read right now and go and start playing with it, then you can go back here and continue reading :).
---A couple of days later---
Hi again, how did you went with NHibernate? Is a great tool, isn't?
Now I have a couple of questions for you:
What are the most difficult parts in NHibernate?, if your answer is "Configuration, Mapping and Querying" then this post will help you to get ride of those problems.
For the configuration and mapping problems, there is a project named Fluent NHibernate, which is an API based configuration and entities mapper tool which eliminate the need for all those XML files.
For the querying problem, there is another project from the NHibernate Contrib Project named LINQ to NHibernate which can be downloaded from here, this allows you to start using NHibernate in the same fashion as with LINQ to SQL making a lot of easier and fun to work with it.
For further reading of the Fluent NHibernate project you could check:
http://nhforge.org/blogs/nhibernate/archive/2008/09/02/a-fluent-interface-to-nhibernate-part-1.aspx
For further reading of the LINQ to NHibernate project you could check:
http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/11/26/linq-to-nhibernate.aspx
In my next article I'll show you an example of how you can combine both tools and get a nice app running.
Bye bye.


3 comments:
Awesome! i never used nhibernate or linq, but after reading for a while i was thinking to use just what you said, fluent nhibernate and linq to nhibernate... but didn't find information about using both, i hope you continue reading.
Do you think it's crazy to use those two (fluent nh and linq 2 nh) in an important new project, knowing that i never used linq or hibernate?
i meant to say "i hope you continue writing", sorry
Hi, thanks for reading this article.
About a practical case where both tools are used, you can check the part two of this article: http://emiajnet.blogspot.com/2009/04/fluent-nhibernate-and-linq2nhibernate.html
But I must say that both of them were being written with a outdated version of L2NH (April - 2009), if you check the Contrib project (http://sourceforge.net/projects/nhcontrib/files/NHibernate.Linq/) you'll see that it was updated on July - 2009, so everything you need to re-check things being said here, and the same for the Fluent NHibernate project which was last updated on October - 2009.
About if you could use this for a real project ... well NHibernate for sure, and the same for FluentNHibernate, L2NH is the tricky one, you would need to check what scenario your application may support given the fact that there are unsupported features to this date (at least with 2009-04 release, things my be different with the latest bits). But everything will depend on your project requirements, is not a simple question to answer.
Hope this helps.
Kind Regards,
Jaime.
Post a Comment