如果没有有关您的映射的更多信息,将无法获得正确的代码,但它会是这样的:
假设您的客户中有一组客户订单,名为“ClientOrders”
//Create the criteria for objects of type 'Client'
ICriteria target = Session.CreateCriteria<Client>();
//create an alias for the client orders, to be able to add the restrictions
target.CreateAlias("Orders", "ClientOrders", NHibernate.SqlCommand.JoinType.LeftOuterJoin);
//Add the restrinctions using an 'Or' to allow any of this two conditions
target.Add(Restrictions.Or(Restrictions.IsNull("Orders.DateCreated"), Restrictions.Eq("Orders.DateCreated",
Session.CreateCriteria<DateTime>().SetProjection(Projections.Max("Orders.DateCreated")).UniqueResult<DateTime>())));
//Get the list of the clients
target.List<Client>();
同样,这应该只给你一个提示,因为没有你的映射,就不可能知道你在那里有什么。希望能帮助到你...