开发者

NHibernate: why do non-persistent properties have to be marked as virtual for lazy loading

开发者 https://www.devze.com 2023-01-07 02:08 出处:网络
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 implementatio

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

0

精彩评论

暂无评论...
验证码 换一张
取 消