NHibernate:Lazyload单个属性 [英] NHibernate: Lazyload single property

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

问题描述

我目前已将博客引擎从Linq2Sql移到了NHIbernate.

I have currently moved my blogengine over from Linq2Sql to NHIbernate.

我陷入了以下性能问题: 我得到一个表:"Posts",其中包含ID,标题,PostContent,DateCreated列等等.

I'm stuck at the following performance problem: I got one table: 'Posts', that has Id, Title, PostContent, DateCreated collumns and so on.

问题在于,当我创建最近帖子列表"时,我不希望整个PostContent.

The problem is that, when I'm creating the "Recent posts list", I don't want the whole PostContent.

在Linq2Sql中,您可以在单个属性上设置延迟加载,因此直到您真正请求该属性后,它才成为SQL查询的一部分.

In Linq2Sql you can set lazy loading on a single property, so it won't be part of the SQL query until you actually ask for the property.

我尝试通过Fluent NHibernate做到这一点:

I tried doing this with Fluent NHibernate, by doing this:

Map(x => x.PostContent).LazyLoad();

没有成功.到处搜寻,NHibernate似乎不支持此功能,所以我的问题是,如何解决此问题?

It didn't work out. Googling around, it seems that NHibernate doesn't support this, so my question is, how can I fix this?

在不将内容移动到单独的表的情况下,是否真的不可能延迟加载我的属性?

Is it really not possible to lazy load my property without moving the content to a seperate table?

提前谢谢!

推荐答案

更新:此功能现已在NHibernate干线中提供.

Update: this capability is now available in the NHibernate trunk.

有关详细信息,请参见 Ayende的博客,其中的样本恰好是您在此描述的情况的.

See details on Ayende's blog, where the sample is exactly the scenario you describe here.

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

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