views:

159

answers:

2

I need some tutorials on how to get started with nHibernate and Fluent nHibernate. I'm coming from an Entity Framework background (which seems easier to use). I've tried sites like http://www.summerofnhibernate.com/ to get a grasp on nHibernate itself, but it seems outdated.

I'd like to generate a mapping of my database tables (al la Entity Framework), and do simple CRUD using nHibernate. I'm also using ASP.NET MVC and Visual studio 2010. Thanks.

+8  A: 

Although a few years old, Summer of NHibernate concepts are pretty much intact and that's what it teaches you best. If you're a patient learner, start there.

On the side of Fluent NHibernate, the best tutorial is still the official one. The minor gripe it has is that it assumes that you're coming from an NHibernate raw background, so it's not particularly great explaining how to configure NHibernate (i.e. installing binaries for it and any given database).


A bit more advanced resources:

Rafael Belliard
do you recommend learning current nHibernate now or wait on version 3.0?
Shawn Mclean
@Shawn McIean: Now. As soon as possible. The core won't change and the biggest difference is something that will make the LINQ crowd (all of us) cry from joy: http://nhforge.org/blogs/nhibernate/archive/2009/12/17/queryover-in-nh-3-0.aspx
Rafael Belliard
@Shawn McIean: Currently, NHibernate *does* support LINQ operations, but NH 3.0 will truly grasp and use lambda expressions to the fullest. NH3 won't break your code, but I'll just add another **friendly++** way of querying the database.
Rafael Belliard
A: 

Just like to suggest you to have a look at iBatis.Net (another open source ORM). iBatis in Java is already powerful and is finding place in all the large scale enterprise wide applications iBatis

iBatis in comparison to NHibernate differs in specifying the SQL queries. NHibernate generates all the SQL queries automatically where as in iBatis, you get to mention all the queries in XML files. This method scales very well and you don't need to recompile all the code when you need to change the SQL query. Just need to change the XML files. This is proving to be a maintenance delight for the enterprises. You can do more research and select which ORM to go for. But in my view iBatis.Net has a larger role to play.

A_Var
So you set the queries in XML files that the compiler **cannot** check? Do note that although today's NHibernate (2.1.2) uses magic strings here and there, that can be easily resolved by using the NHibernate.Linq provider or the newer NH 3.0, with full support for lambda expressions. I find it hard to believe someone would want to specify all their queries on XML files, which by the way, is something NHibernate already **can** do, just that no one's does so. LINQ vs Magic XML strings? It's 2010.
Rafael Belliard