1

I want to store my object in ASP.NET Session. This object has some lazy loaded properties. When I do postback to my page and get my object from Session, this properties throw LazyInitializationException. Can I rebind this object to newly creates Nhibernate Session to retrieve this properties or I have to create Session and get this object on each request?

1 Answer 1

1

You need to eagerly fetch those objects at the moment you send the SQL query so that they are populated and accessible from the session on the next request. Once the session that was used to retrieve the parent object is closed you cannot fetch them anymore.

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

3 Comments

I dont want feth them eagerly, beacuse they are quite large. So, as I understand, I need to fetch this object on each request. Thanks
But if you are going to store it into the ASP.NET session why would you fetch it on each request? Why not fetch the whole object once and then cache it?
Maybe I do something wrong? but some objects may contain more than 10000 child objects.

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.