Order by collection count using ICriteria & NHibernate

前端 未结 2 853
时光取名叫无心
时光取名叫无心 2020-12-21 18:41

Using the standard NHibernate example of Cats and Kittens, how would I use ICriteria to sort Cats based on Kitten count? For example, I want to do something like:



        
相关标签:
2条回答
  • 2020-12-21 18:46

    In HQL you can do it like this:

    select cat
    from Eg.Cat cat
    join cat.Kittens kitten
    group by cat
    order by count(kitten) asc
    
    0 讨论(0)
  • 2020-12-21 19:00

    See http://forum.hibernate.org/viewtopic.php?p=2401219

    It's Java Hibernate but almost the same thing (Projection, AddOrder)

    0 讨论(0)
提交回复
热议问题