I finally took the time today to get NHibernate Query Generator running in my project. I should have done this a long time ago!
NHQG makes querying more intuitive then the Criteria.
Ayende is the creator – here is one link that show him introducing version 1.5 (I’m using 1.8)
You can download it here
To integrate with VS 2008, there is a registry key needed you can get here (thank you Ryan Cromwell!). Ryan has a link here and here (I did this one, not the first one – but I will look into it) about installing and using it.
Last link for the topic – building up a dynamic query with the NHQG QueryBuilder
I used this with my Spring.NET/NHibernate Dao classes fairly easy. My base class would have something like ‘FindAll(DetachedCriteria criteria, Order order)’
So, my query is something like this then:
List<Person> people = PersonDao.FindAll(Where.Person.FirstName == ‘Steve’, OrderBy.Person.LastName);
It supports ‘Where’, ‘Group’ ‘Projection’ and ‘OrderBy’. You build up the queries just like OO collection building (similiar perhaps to Linq).