views:

123

answers:

3

Possible Duplicate:
What is NHibernate?

I've heard the name NHibernate used a lot, but I don't really understand what it is. I've read the Wikipedia article, but I don't understand how using NHibernate in my C# applications (desktop w/ WPF, web w/ ASP.NET MVC) will:

  • Change the code
  • Be easier/faster

Should I look into using NHibernate in my projects?


UPDATE: Thanks for identifying this as a dupe! I didn't realize that this had already been asked.

I guess my real question is about NHibernate versus Linq to SQL (which I've been using in all of my applications), but that has already been asked here and here.

Thanks, everyone! :)

+3  A: 

The main purpose of NHibernate is described in the Wikipedia article as well:

NHibernate's primary feature is mapping from .NET classes to database tables (and from CLR data types to SQL data types). NHibernate also provides data query and retrieval facilities.

NHibernate generates the SQL commands and relieves the developer from manual data set handling and object conversion, keeping the application portable to most SQL databases, with database portability delivered at very little performance overhead.

0xA3
+1  A: 

NHibernate saves you from re-inventing the wheel. 90% time you choose file new project its going to be a CRUD(Create, Read, Update, and Delete) project with Database back end. NHibernate does a lot of that work for you hopefully taking away some of the tedium of having to write a new data access layer for every project. If you write to a database I would say yes you should look into NHibernate, but there are a lot of ORMS out there. I say try them all.

Aaron
+1  A: 

NHibernate is an ORM (Object Relational Mapper). Its purpose is to map objects in your OO application to tables in a database for persistence.

Why would you need it? Because it can save you from writing a lot of tedious ADO.NET code. Essentially it enhances developer productivity when developing CRUD applications, that is, applications whose main purpose is to Create, Read, Update, and Delete data in a database.

NHibernate is open source, and you need to realise that you are making your application dependent on third party libraries, whose long term goals may diverge from yours.

If you want the productivity of an ORM without introducing this dependency, consider Entity Framework, or Linq2SQL (noting that Linq2SQL locks you into SQL Server).

And finally if you don't need the productivity enhancement of an ORM, and you want absolute control, stick to plain old ADO.NET.

saille
It would be interesting to know just how does the OP currently works with database. There might be a change he hasn't done much even with ADO.NET, which would explain why he isn't crying his way out of it. =P
Rafael Belliard