I was just wondering... how many of you have tried using an Object Relational Mapper... perhaps something like NHibernate instead of the DataSet:

NHibernate is a port of Hibernate Core for Java to the .NET Framework. It handles persisting plain .NET objects to and from an underlying relational database. Given an XML description of your entities and relationships, NHibernate automatically generates SQL for loading and storing the objects. Optionally, you can describe your mapping metadata with attributes in your source code.

NHibernate supports transparent persistence, your object classes don't have to follow a restrictive programming model. Persistent classes do not need to implement any interface or inherit from a special base class. This makes it possible to design the business logic using plain .NET (CLR) objects and object-oriented idiom.

Being a port of Hibernate 2.1, the NHibernate API is very similar to that of Hibernate. All Hibernate knowledge and existing Hibernate documentation is therefore directly applicable to NHibernate. Take a look at the list of Differences between Hibernate and NHibernate for a detailed comparison of Hibernate for Java and .NET.

Re: Architecture General Have you tried NHibernate?

Frank Wang

Yes, I'm studying it. I'm very supprised few people use it in such a large community.

Re: Architecture General Have you tried NHibernate?


It is a very well designed and powerful ORM layer. Saves you lot of time. Like any other architectural decisions, you have to weigh against your goals.

It is not something new, where your risk factor is very high. Hibernate project has been employed in many projects in the Java world. NHibernate is an exact port of Hibernate.

Re: Architecture General Have you tried NHibernate?


If you want to try something really different - have a look at Persistor.NET. It provides persistence for really object oriented development - there is no mapping at all.

Save the objects!

Re: Architecture General Have you tried NHibernate?

Greg Young

"provides a revolutionary new way of object oriented programming".

As for "no mapping at all" ... The problem as most know is the dual schema problem .. there are lots of ways of making the dual schema a single schema .. the problem is that the dual schema problem exists for a reason and all the work arounds are trade offs on one side or the other.

For the main question; I use nhibernate daily as my main OR mapper ... never had any major problems.



Re: Architecture General Have you tried NHibernate?

Nikola Kasev


I have used NHibernate in several projects and I am quite happy with the productivity gain and the possibilities of the tool.

You can check for more information. You can also download the sample solution that is extracted from a real-world scenario.


- Nikola

Re: Architecture General Have you tried NHibernate?


I am just wondering that how I can use local variables in HQL using Nhibernate. It is almost impossible to find an exact sample for the following case

"select recepient from RegisteredUser as ru inner join ru.Recepients as recepient inner join fetch recepient.Forms as form where year(form.Date) = '2007' and ru.Id = ", Id, NHibernate.NHibernateUtil.Guid);

Infact int he above statement I would like to replace 2007 with a local variable.