NHibernate:多对一和懒惰 [英] NHibernate: many-to-one and lazy

查看:73
本文介绍了NHibernate:多对一和懒惰的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于NHibernate 1.2(webapp C#aspnet 3.5)和延迟加载有一些我不了解的地方,我找不到明确的答案:多对一支持延迟加载吗?

There is something regarding NHibernate 1.2 (webapp C# aspnet 3.5) and lazy loading that I don't understand and I can't find some clear answer: does many-to-one support lazy loading?

假设我们有一些Person对象和Squeletton对象.这两个对象都很大,具有许多属性. Person有一个且只有一个Squeletton:myPerson.Squelleton.

Let's say we have some Person object and a Squeletton object. Both objects are big with many properties. A Person has one and only one Squeletton: myPerson.Squelleton.

Person的映射:<many-to-one class='Squeletton' name='Squeletton' column='id_squeletton' lazy='proxy' />

我不希望每次Person都加载Squeletton属性.使用NHProfiler,即使我不访问该属性,也可以看到对Squeletton的选择"请求.

I don't want the Squeletton property to be loaded every time Person is. Using NHProfiler I can see "select" requests for Squeletton even if I don't access the property.

出什么问题了:映射?不良使用多对一? NHibernate版本?如何在Squeletton属性上进行一些延迟加载?

What is wrong: mapping? bad use of many-to-one? NHibernate version? How can I have some lazy loading on Squeletton property?

谢谢.

推荐答案

默认为延迟加载,但它可以很好地适应您的映射.

Lazy loading is the default, but it should work fine with your mapping.

您是否100%确定不访问该酒店?也许在调试器中观看它?

Are you 100% sure you are not accessing the property? Watching it in the debugger, maybe?

无论如何,您肯定应该将NHibernate更新到最新版本3.2,因为1.2确实已经过时并且已经不被支持(如2.x)

In any case, you should certainly update NHibernate to the last release, 3.2, as 1.2 is really outdated and has been unsupported for ages (as has 2.x)

这篇关于NHibernate:多对一和懒惰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆