With the introduction of NHibernate 3.2, a new mapping feature was introduced: mapping-by-code. Conceptually this is similar to Fluent NHibernate and the Code First mapping in Entity Framework. I really liked Fluent NHibernate but I had a hard time getting used to the out-of-the-box mapping-by-code feature. It' is not documented at all so I was really happy when I discovered this blog series by Adam Bar. As he says it himself it’s probably the only complete guide to mapping-by-code on the web so far. (I only found the blog of Fabio Maulo as another resource)
Here is the full table of contents of the mapping-by-code series.
- First impressions
- Naming convention resembling Fluent
- Property
- Component
- ManyToOne
- inheritance
- dynamic component
- Set and Bag
- OneToMany and other collection-based relation types
- concurrency
- OneToOne
- Join
- Any
- List, Array, IdBag
- Map
- Id, NaturalId
- composite identifiers
- entity-level mappings
Thanks Adam!