NHibernate:为什么非持久属性必须标记为虚拟才能延迟加载
我了解到为了允许延迟加载,NHibernate 需要生成一个扩展 POCO 类的代理类。所以我猜 NHibernate 需要重写持久化属性的实现,并且你必须将它们标记为虚拟的。
我不明白的是为什么我必须把几乎所有其他东西都标记为虚拟。例如,我必须标记一个 IsValid 属性,该属性引用其他属性,但显然本身不是持久的,而且奇怪的是,我也必须将该类可以发出的所有事件标记为虚拟。
有谁知道这是为什么吗?我只是好奇。
谢谢
大卫
I kind of get that in order to allow lazy loading, NHibernate needs to generate a proxy class which extends the POCO class. And so I guess NHibernate needs to override the implementation of the persisted properties, and you have to mark them as virtual.
What I don't get is why I have to go round marking almost everything else as virtual as well. For example, I had to mark an IsValid property, which refers to the other properties but obviously isn't itself persistent, and bizarrely I had to mark all the events the class can emit as virtual too.
Anyone know why this is? I'm just curious.
Thanks
David
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论