R – NHibernate: Lazyload single property

lazy-loadingnhibernate

I have currently moved my blogengine over from Linq2Sql to NHIbernate.

I'm stuck at the following performance problem:
I got one table: 'Posts', that has Id, Title, PostContent, DateCreated collumns and so on.

The problem is that, when I'm creating the "Recent posts list", I don't want the whole PostContent.

In Linq2Sql you can set lazy loading on a single property, so it won't be part of the SQL query until you actually ask for the property.

I tried doing this with Fluent NHibernate, by doing this:

Map(x => x.PostContent).LazyLoad();

It didn't work out. Googling around, it seems that NHibernate doesn't support this, so my question is, how can I fix this?

Is it really not possible to lazy load my property without moving the content to a seperate table?

Thanks in advance!

Best Answer

Update: this capability is now available in the NHibernate trunk.

See details on Ayende's blog, where the sample is exactly the scenario you describe here.

Related Topic