是否可以在不触及映射的情况下使用HQL进行急切加载? nHibernate完全忽略了“左连接提取”表达式。
var query = Session.CreateQuery("from o in Member left join fetch o.Photos");
query.List<Member>();
生成的SQL是
SELECT this_.Id as Id7_1_, this_.Name as Name7_1_, this_.AltNames as AltNames7_1_,
this_.Tags as Tags7_1_, this_.Loved as Loved7_1_, profile2_.id as id6_0_,
profile2_.Website as Website6_0_, profile2_.Email as Email6_0_,
profile2_.Shop as Shop6_0_
FROM Member this_
left outer join member_profile profile2_ on this_.Id=profile2_.id
limit 10;
然后10个声明抓住了照片。 MemberProfile映射为OneToOne。