views:

185

answers:

2

NHibernate question:

Say I have a SQL table Person and it has a Picture column ( OLE Object ) . I have a class Person and it has : byte[] Picture attribute.

Is it possible to map like this ?

<property name  = "Picture" column = "Picture"  type = "System.Byte[]"  lazy="true"  />

Does the "lazy" keyword have any effect on properties or can it only be used when working with collections / bags etc?

+1  A: 

I have not found any way to get this to work, but the following two ways may help you around the problem you imply:

  • You can map two classes for the same table, one including the byte array, the other not.

  • You can include a many-to-one property mapping to the same table, where the child class has the byte array included, and you then access the binary using Person.PersonPicture.Picture rather than just Person.Picture; the intermediate class can now be lazy loaded.

Neither is ideal, but they do work. Short answer - collections and many-to-one properties can be lazy loaded, straight properties not.

David M
+2  A: 

It appears that this feature just landed in the NHibernate trunk:

http://ayende.com/Blog/archive/2010/01/27/nhibernate-new-feature-lazy-properties.aspx

Michael Maddox