3

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

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

Comments

3

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.