Even though Fluent NHibernate cannot be called mature, I find it to be a really nice companion for NHibernate. At least, it takes away some of the configuration burden that appears to be part of modern software development.

I like compilers, and I want them to do as much work for me as possible. I like static analysis and how it can help me make permanent improvements to how I program. When we start putting parts of our programs into configuration files, the compile time security is eroded.

Ok, so Fluent NHibernate gives us NHibernate mapping rules in code. And it uses some language features that I appreciate (generics, lambda expressions), e.g.

public class MyClassMap : ClassMap<MyClass> {
public MyClassMap() {
Id(c => c.Id);
Map(c => c.Name);
References(c => c.OtherObject);

With the above, the Hibernate mapping will break at compile-time, when changes are made. At least, some of the time. Nothing is perfect.

Oh, and there’s a convenience class for testing too:

public void CanCorrectlyMapEmployee()
new PersistenceSpecification<MyClass>(session)
.CheckProperty(c => c.Id, 1)
.CheckProperty(c => c.Name, “rasmoo”)
.CheckReference(c => c.OtherObject, new OtherObject())