NHibernate中的延迟加载 [英] Lazy Loading in NHibernate

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

问题描述

如果客户有许多附加订单.您将如何使用NHibernate延迟加载订单列表.

If a Customer has many Orders attached to them. How would you lazy load the Orders List using NHibernate.

是否需要设置映射文件?任何帮助或示例都是很好的.

Is it something that needs to be set up mapping file? any help or an example would be great.

推荐答案

此处有一篇不错的文章:

Heres a good article:

http://blogs.chayachronicles.com/sonofnun/存档/2007/03/30/230.aspx

来自以上文章:

最常见的是简单地用'lazy ="true"'属性标记该类,或在映射声明中放置'default-lazy ="true"':

The most common is to simply mark the class with the 'lazy="true"' attribute or place 'default-lazy="true"' in the mapping declaration:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="@core.assembly@"
 default-access="nosetter.camelcase-underscore" default-lazy="true">

<class name="Cei.eMerge.Core.Domain.Contacts.Contact" table="Contact" lazy="true" >

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

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