NHibernate select most recent record that meets criteria
asp.net, c#, nhibernate, provider
Solution
Can you add an Order?
ICriteria cr = Session.CreateCriteria<MyType>();
cr.AddOrder(Order.Desc("Id"));
MyType justone = cr.UniqueResult();
Problem
Last night I started working on an NHibernate provider. I'm creating a criteria that several records will match, however I only want to return the most recent record (the record with the largest Id). I thought UniqueResult() would do this it cannot be used if a list would be returned otherwise. I could theoretically select the full list and then return the desired record, but I believe there is a better way.