nHibernate-IStatelessSession和FetchMany返回多个父记录 [英] nHibernate - IStatelessSession and FetchMany returning multiple parent records
本文介绍了nHibernate-IStatelessSession和FetchMany返回多个父记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下linq语句:
I have the following linq statement:
var query = from p in session.Query<Parent>().FetchMany(x => x.Children)
select p;
我最终为Children中的每个Child创建了一个新的Parent对象.因此,如果我有5个孩子,我会得到5个单独但相同的Parent对象.这是预期的行为吗?如果我使用ISession,则可以预期获得1个父级.
I end up with a new Parent object for each Child in Children. So if i had 5 Children, I would get 5 separate, but identical, Parent objects back. Is this the intended behavior? If i use ISession, I get 1 Parent as expected.
推荐答案
这是预料之中的,因为无状态会话不会跟踪对象.因此,每一行都会产生一个新实例.
This is expected, because Stateless Sessions do not track objects; therefore each row results in a new instance.
这篇关于nHibernate-IStatelessSession和FetchMany返回多个父记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文