How do I get row count using the NHibernate QueryOver api?

前端 未结 4 795
余生分开走
余生分开走 2021-02-02 08:45

I\'m using the QueryOver api that is part of NHibernate 3.x. I would like to get a row count, but the method I\'m using returns all objects and then gets the count of the colle

4条回答
  •  既然无缘
    2021-02-02 09:27

    After a bit of playing around with the api, this will do it:

    _session.QueryOver()
        .Select(Projections.RowCount())
        .FutureValue()
        .Value
    

    If you don't want to return it as a future, you can just get the SingleOrDefault() instead.

提交回复
热议问题