views:

43

answers:

1

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

+3  A: 

There is an excellent discussion about this on Davy Brion's Blog

DanP
lol @ Intellectual Masturbation!Thanks again Dan.
David
It makes complete sense if you think about it...what's to stop you from having a readonly property that performs some operation on a persistent property, etc?
DanP