nHibernate version: 1.2.1 GA
Name and version of the database you are using: Sql2k
Is it possible to set the max results on a detached query (or subquery)?
For example, say I have two tables: Person & Payment. I want to get the the Person details for person who made the latest Payment. Code would be something like:
Code:
DetachedCriteria dc = DetachedCriteria.For(typeof(Payment));
dc.AddOrder(new Order("PaymentDateTime", false));
dc.SetProjection(Projections.Property("PersonId"));
ICriteria c = session.CreateCriteria(typeof(Person));
c.Add(Subqueries.PropertyIn("PersonId", dc));
(Yes, I know there are probably better ways of constructing the query, but due to reasons I cant go into here, I can't make a join - I have a to project & Subquery this way!)
I want to add the following line, but it isn't acceptable nHibernate:
Code:
dc.SetMaxResults(1);
Any ideas?