nhibernate queryover不会以多对多的joinalias迅速加载 [英] nhibernate queryover not loading eagerly with a many to many joinalias
本文介绍了nhibernate queryover不会以多对多的joinalias迅速加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正试图从我的User对象中加载多对多集合中的角色.
I'm trying to eager load roles in many to many collection off of my User object.
Role role = null;
IQueryOver<User, User> query = session.QueryOver<User>()
.Fetch( p => p.Roles).Eager
.JoinAlias( q => q.Roles, () => role)
.Where(() => role.Active == true);
为我提供了具有未初始化角色成员的用户对象.如果删除joinalias,则将它们初始化就好了.这只是NH3的错误还是我做错了什么?
leaves me with user objects that have uninitialized roles members. If I remove the joinalias, they are initialized just fine. Is this just an NH3 bug or am I doing something wrong?
推荐答案
另一种渴望加载的方法是设置LeftOuterJoin.在类似情况下
Another way to make eager load is to set LeftOuterJoin. It helped to us in a similar scenario
Role role = null;
IQueryOver<User, User> query = session.QueryOver<User>().Fetch( p => p.Roles).Eager
.JoinAlias( q => q.Roles, () => role, JoinType.LeftOuterJoin)
.Where(() => role.Active == true);
这篇关于nhibernate queryover不会以多对多的joinalias迅速加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文