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

前端 未结 4 856
余生分开走
余生分开走 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:47

    Another method:

    int employerCount = session
      .QueryOver()
      .Where(x => x.EmployerIsActive) // some condition if needed
      .Select(Projections.Count(x => x.EmployerId))
      .SingleOrDefault();
    

提交回复
热议问题