虚拟属性和延迟加载 [英] virtual properties and lazy loading

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

问题描述

按定义,虚拟属性或方法是要重写的子类可见的方法.但是,例如,NHibernate使用虚拟属性来确保延迟加载.

By definition virtual properties or methods are methods visible to sub classes to be overridden. But, NHibernate for example uses virtual properties to ensure lazy loading.

我的问题不是关于NHibernate,而是如何使用虚拟属性实现延迟加载?我不知道有关于虚拟属性的任何隐藏行为吗?

My question is not about NHibernate, but how you could use virtual properties to achieve lazy loading? Are there any hidden behaviors about virtual properties that I don't know?

推荐答案

事实上,它们被声明为虚拟的,这使得NHibernate可以覆盖该属性并为其创建代理实现-反过来,他们可以使用该代理在服务器上实现延迟加载该属性的首次访问权限.

The fact that they are declared virtual allows NHibernate to override the property and create a proxy implementation for it - the proxy in turn they can use to implement lazy loading on the first access of the property.

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

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