Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

virtual properties and lazy loading

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.

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?

like image 316
Sleiman Jneidi Avatar asked Jan 11 '12 23:01

Sleiman Jneidi


1 Answers

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.

like image 92
BrokenGlass Avatar answered Oct 12 '22 23:10

BrokenGlass