NHibernate and the specification pattern

This is my first guest post at Agile-Code! I wish to thank my friend Zoran Maksimovic (@zoranmax) for the invitation! Hope the blog’s readers like it! :) The Specification pattern is well known to .NET developers and has gained significant momentum with the introduction of LINQ expressions. There are lots of implementations, but, for one reason or the other, I wasn’t really happy with any of them, so I decided to write my own, specifically for working with NHibernate. Using my implementation of the specification pattern, you can write detached LINQ queries (something that NHibernate does not have at the moment) which can then be applied to NHibernate for obtaining results. As an appetizer, here are some examples: var specification = Specification.Create(p => p.Name != ""); var isSatisfied = specification.IsSatisfiedBy(new…
Read More