Today I was browsing through the NHibernate trunk. I discovered a nice new feature. Before lazy loading was only supported on associations, from now on it also becomes available on properties!
Imagine, you have a customer object where one of it’s properties is an image. By specifying this as a lazy property it will only be loaded when you explicitly call it.
1: <property name="Image" lazy="true"/>
Ok, this looks nice, but of course sometimes you want to do eager loading. What do you need to do then? Just add some extra info to your HQL and you are done.
1: var customers = session.CreateQuery("from Customer fetch all properties");