NHibernate returning duplicate object in child collections when using Fetch

后端 未结 5 1855
轮回少年
轮回少年 2021-02-19 01:35

When doing a query like this (using Nhibernate 2.1.2):

 ICriteria criteria = session.CreateCriteria()
                .SetFetchMode(\"ChildColl         


        
5条回答
  •  执笔经年
    2021-02-19 02:17

    You're doing a cartesian product here. Don't. Instead, fetch each collection separately.

    BTW: this isn't something NHibernate-specific, the same applies to any ORM in any platform, or even pure SQL without any ORM at all. In general, you don't want to fetch N*M rows when you can fetch N+M instead.

提交回复
热议问题