Ben Foster
Ben Foster

Reputation: 34800

NHibernate - is property lazy loading possible?

I've got some binary data that I store and was going to separate this out into a separate table so it could be lazy loaded.

However, i then came across this post by Ayende (http://ayende.com/Blog/archive/2010/01/27/nhibernate-new-feature-lazy-properties.aspx) which suggests that property lazy loading is now possible.

I have added the lazy="true" attribute to my property mapping but the field is still loaded from the database (I am using a simple text field to test).

My query:

                return _session.CreateQuery("from Product")
                .SetMaxResults(1)
                .UniqueResult<Product>();

Mapping:

<property name="Description" type="string" column="FullDescription" lazy="true"/>

Has anyone been able to get this working? Personally I prefer this approach than having to add another table to my database.

Upvotes: 2

Views: 343

Answers (2)

mxmissile
mxmissile

Reputation: 11673

As the article states: "This feature is now available on the NHibernate trunk". So either NH 3.0 or the latest trunk.

Upvotes: 3

Claudio Redi
Claudio Redi

Reputation: 68400

It will be possible on nhibernate 3.0, on the current version is not possible. You can download the trunk code or wait for the 3.0 version :-)

Upvotes: 2

Related Questions