Nhibernate Facility Lazy loading problem?

It's by design. You have to keep your session open.

It's by design. You have to keep your session open. If you are doing web, I suggest you to open the session at the begin of the request and close it at the end.

Get the samples from this article: codeproject.com/KB/architecture/Naspx.

Im using "Nhibernate Facility" which is supposed to handle all management of session... – kaivalya Jun 29 '10 at 12:58 1 Maybe, but in your code, you dispose the session explicitly using "Using". – Pierre Jun 29 '10 at 13:09 Nhibernate Facility has a caching mechanism that caches the objects and reuses them in the same context. I updated my question after finding out that my problem was not connected to the using statements.

Lazy loading is failing regardless of the using statements as soon as I register the required SessionWebModule – kaivalya Jun 29 '10 at 16:20.

If you're using MVC, I use an action filter to close my nhibernate sessions public class NbernateSessionAttribute : ActionFilterAttribute { public NbernateSessionAttribute() { Order = 100; } public override void OnResultExecuted(ResultExecutedContext filterContext) { if (filterContext. IsChildAction) return; SessionSource. EndContextSession(); } } SessionSource is where I'm managing creating my sessions... and the SessionSource.

EndContextSession() method essentially calls: public static void EndContextSession() { var session = CurrentSessionContext. Unbind(Factory); if (session! = null && session.

IsOpen) { try { if (session. Transaction! = null && session.Transaction.

IsActive) { // an unhandled exception has occurred and no db commit should be made session.Transaction.Rollback(); } } finally { session.Close(); session.Dispose(); } } }.

I belive you have to set the isWebattribute to true.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions