We have a query that selects rows depending on the value of another, ie. the max. I don't think that really makes much sense, so here is the query:
var deatched = DetachedCriteria.For<Enquiry>("e2")
.SetProjection(Projections.Alias(Projections.Max("Property"), "maxProperty"))
.Add(Restrictions.EqProperty("e2.EnquiryCode", "e.EnquiryCode"));
session.CreateCriteria(typeof(Enquiry), "e")
.Add(Subqueries.PropertyEq("Property", deatched))
.AddOrder(Order.Asc("EnquiryCode"));
My question is, is this the best way? Can anyone suggest a better way?