How to get a distinct result with nHibernate and QueryOver API?

前端 未结 4 2085
悲&欢浪女
悲&欢浪女 2020-12-25 10:01

I have this Repository method

    public IList ListMessagesBy(string text, IList tags, int pageIndex, out int count, out int pageSi         


        
4条回答
  •  盖世英雄少女心
    2020-12-25 10:31

    If you're using the ICriteria API, you need:

    .SetResultTransformer(new DistinctEntityRootTransformer())
    

    If you're using the QueryOver API, you need:

    .TransformUsing(Transformers.DistinctRootEntity)
    

    But beware, this all occurs on client side, so all the duplicate rows are still pulled.

提交回复
热议问题