You people are already working with Nhibernate criteria queries where we have to use magic strings to tell nhibernate about property names. Nhibernate version we have in gold does have another API called QueryOver API for compile time safe queries. You can make use of Visual Studio intellisense with QueryOver API while writing queries
This comes with multiple advantages for example reduced coding time, no typos and no more broken queries if you change the name of some property but forgot to update the change in queries where name was hard coded. In Gold R8 I wrote few helper methods in NhibernateHelper class to help create QueryOver handle. Let me give you some quick examples
Code: Select all
// CRITERIA API
Product p = NHibernateHelper.CreateCriteria<Product>()
.Add(NHibernate.Criterion.Restrictions.Eq("Id", 1))
.UniqueResult<Product>();
// QUERYOVER API
Product p = NHibernateHelper.QueryOver<Product>()
.Where(p => p.Id == productId)
.SingleOrDefault<Product>();
You can see the lambda expression in where clause is making it compile time safe. You can learn more about QueryOver API here
http://nhforge.org/blogs/nhibernate/arc ... h-3-0.aspx
Give it a try I believe you will love it. Specially the simple queries are super easy to write using QueryOver API due to lambda expressions and intellisense.