Best way to manage your session in NHibernate?

I am new to NHibernate (my first big project with it).
I used a simple data access method by creating an ISession object in the using block to capture my object or list of objects, and thus the session was destroyed after exiting the code block.

This does not work in situations where lazy loading is required.
For example, if I have a Customer object that has a property that is a collection of Orders, then when I try to do lazy loading, I get a Hibernate exception.
Anyone using a different method?

+5
source share
4 answers

SummerOfNHibernate - ... , , - 5 6.

+2

. , ( ). , , . , .

, .

-, , , session-per-httpRequest. HttpModule, / . HttpContext.Items NOT STATIC VARIABLE. < --- , .

RhinoCommons .

+1

- ( ASP.NET), NHibernate Best Practices ASP.NET CodeProject.

0

All Articles