How do I select the Count(*) of an nHibernate Subquery's results

后端 未结 6 1245
名媛妹妹
名媛妹妹 2021-01-04 21:52

I need to do the following for the purposes of paging a query in nHibernate:

Select count(*) from 
(Select e.ID,e.Name from Object as e where...)
         


        
6条回答
  •  我在风中等你
    2021-01-04 22:06

    var session = GetSession();
    var criteria = session.CreateCriteria(typeof(Order))
                        .Add(Restrictions.Eq("Product", product))
                        .SetProjection(Projections.CountDistinct("Price"));
    return (int) criteria.UniqueResult();
    

提交回复
热议问题