在Fluent nHibernate中为2列添加AddOrder

时间:2013-10-16 09:37:37

标签: sql fluent-nhibernate

我想知道以下SQL查询的标准:

SELECT * FROM PageDetails WHERE PageRoom_Id = 4 Order By SentDate DESC, Id DESC

目前我使用的标准如下:

var criteria = unitOfWork.CurrentSession.CreateCriteria(typeof(PageDetails))
               .CreateAlias("PageRoom", "pageRoom")
               .Add(Restrictions.Eq("pageRoom.PageRoom_Id", pageRoom.PageRoom_Id))
               .AddOrder(Order.Desc("SentDate"));

如何再添加一个订单?

1 个答案:

答案 0 :(得分:0)

试试这个:

var criteria = unitOfWork.CurrentSession.CreateCriteria(typeof(PageDetails))
               .CreateAlias("PageDetails", "pageDetails")
               .Add(Restrictions.Eq("pageDetails.PageRoom_Id", pageRoom.PageRoom_Id))
               .AddOrder(Order.Desc("SentDate"))
               .AddOrder(Order.Desc("Id"));