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

前端 未结 4 793
余生分开走
余生分开走 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-02 09:42

    Im using like this:

    public int QuantidadeTitulosEmAtraso(Sacado s)
        {
            TituloDesconto titulo = null;
            Sacado sacado = null;
    
            var titulos =
                    _session
                    .QueryOver(() => titulo)
                    .JoinAlias(() => titulo.Sacado, () => sacado)
                    .Where(() => sacado.Id == s.Id)
                    .Where(() => titulo.Vencimento <= DateTime.Today)
                    .RowCount();
    
        }
    

提交回复
热议问题