Get Distinct result set from NHibernate using Criteria API?

后端 未结 6 2068
被撕碎了的回忆
被撕碎了的回忆 2020-12-03 02:50

I\'m trying to get distinct results using the Criteria API in NHibernate. I know this is possible using HQL, but I would prefer to do this using the Criteria API, because th

6条回答
  •  时光取名叫无心
    2020-12-03 03:16

    I also ran into the problem of the non-distinct number of items (I use a fetch="join" in my mapping file). I used Linq To Nhibernate to solve the problem, which is used in the following way:

           var suppliers = (from supplier in session.Linq()
                            from product in supplier.Products
                            where product.Category.Name == produtCategoryName
                            select supplier).ToList().Distinct();
    

提交回复
热议问题