I have seen several items lately, particularly from Ayende of course (I love the idea of Bumbler!) Sam considers it Noteable. In the past, he has also mentioned it in contrast to Microsoft's flagging ORM efforts as a Good Thing.
Time to check it out. I go to NHibernate.org (or rather a page off of Hibernate.org) and check out the Nhibernate Quick Start Guide. In five steps, the first of which you may not need (create a database), the last of which is really several steps to get the configuration and connection objects lashed up, you can begin firing at your database.
The first few examples look good, such as:
User newUser = new User();
newUser.Id = "joe_cool";
newUser.UserName = "Joseph Cool";
newUser.Password = "abc123";
newUser.EmailAddress = "email@example.com";
newUser.LastLogon = DateTime.Now;
session.Save(newUser); // commit all changes to the DB
Seems natural enough. Then we go down a bit to find
Let's say you want to retrieve an object when you know the user ID (eg. During a login process to your site). Once a session is opened it's a one-liner; pass in the key and you're done:
// open another session to get the new user
session = factory.OpenSession();
User joeCool = (User)session.Load(typeof(User), "joe_cool");
Casting? Why are we casting?? Why not create an object of the type you want and get IntelliSense for its columns, properties, and methods? That's what the MyGeneration d00dads architecture lets you do. Here is their canonical example.
And what's up with all the code you have to write? One would assume that NH devotees use code generation for the class with its properties and the
Now a lot of any ORM or DAL tool is what you get used to doing. If NH floats your boat, I won't try to argue you out of it. But I'd love to know if anyone using NH has also tried something a bit more automated, perhaps even SubSonic, which is starting to look very nice in v2.0.
If you have tried something else and still use NH, I'd love to know why.