延迟加载属于主记录的字段 [英] Lazy loading of fields that are part of the main record

查看:57
本文介绍了延迟加载属于主记录的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是NHibernate的相对新手,所以如果这是一个愚蠢的问题,我会事先请您原谅.我已经在Google上搜索并搜索了文档,然后将所有文件都包裹在车轴上.

I'm a relative newbie at NHibernate, so I'll beg forgiveness in advance if this a stupid question. I've googled it and searched the documentation, and am getting all wrapped around the axle.

我正在维护/增强使用NHibernate的相对简单的表的现有应用程序.该表有大约10-12个字段,并且没有外键关系.该表包含大约十二行左右的行,

I'm maintaining/enhancing an existing application that uses NHibernate for a relatively straightforward table. The table has about 10-12 fields, and no foreign key relations. The table contains somewhere around a dozen or so rows, give or take.

两个字段是巨大的Blob(兆字节).结果,在使用远程数据库时,该表要花费过多的时间(4分钟)来加载.

Two of the fields are huge blobs (multi-megabytes). As a result, the table is taking an excessive amount of time (4 minutes) to load when working with a remote DB.

问题是,直到用户选择了其中一行并开始对其进行处理,然后才需要使用这两个字段,然后才需要对他选择的那一行进行操作.

The thing is that those two fields are not needed until a user selects one of the rows and begins to work on it, and then they are only needed for the one row that he selects.

这似乎完全意味着延迟加载.除非我分解现有的数据库架构,并通过一对一映射将那些列放在自己的表中,否则我只是想不明白如何应用它.

This seems like exactly what lazy loading was meant for. I just can't quite figure out how to apply it unless I break up the existing DB schema and put those columns in their own table with one-to-one mapping, which I don't want to.

如果有关系,该程序将使用NHiberate.Mapping.Attributes而不是hbm文件,因此我需要能够更改将传播到hbm的Domain对象的属性.

If it matters, the program is using NHiberate.Mapping.Attributes rather than hbm files, so I need to be able to make alterations in the attributes of the Domain objects that will propagate to the hbm.

感谢您的帮助.

推荐答案

您需要

You need lazy properties IN NHibernate 3 to accomplish this. I assume, but don't know, that you can set that using attributes.

这篇关于延迟加载属于主记录的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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