Saw a very interesting presentation last night by Brendan Erwin, on how he uses NHibernate and FluentNHibernate. FluentNHibernate is a tool that lets you specify your mappings between the database and your domain objects in C# code, instead of in XML. This is awesome for several reasons:
- You can refactor common bits of mappings into helper methods, thus keeping your mappings more DRY.
- It is much more refactoring friendly. It uses lambda expressions and is able to avoid strings for property names. Thus if you rename a property using .NET refactoring or Resharper, the update applies everywhere.
- You get intellisense as you create and edit mappings. You’d be surprised how greatly this improves the process.