In the first post about the new mapping-by-code feature you saw only the very first presentation.
I’ll will try to write more posts about this new feature and all its secrets even if you can learn more using ConfORM.
As in ConfORM even the NHibernate’s mapping-by-code is smarter than XML mapping and may help you in many cases. Well… it is not so smart as ConfORM but smart enough to prevent some common errors.
It’s beginner proof
Let me show you a simple case:
An entity with a collection of components which has a nested component. The beginner may intent this mapping:
hmmmm… a cyclic mapping of the nested component on OwnerAdress property ? Not for sure!! NHibernate knows how create the correct mapping .
It’s even conformist
In these years I saw people writing mappings by-code but class-by-class as in XML… a very conformist attitude. Well… if you feel conformist don’t worry NHibernate 3.2 can be conformist too.
Then you can add it to the ModelMapper in this way:
NHibernate 3.2 too sexy by far!!!