I use session per request with all my web apps. NH also has built-in
support for managing the session using an ICurrentSessionContext
implementation. some information on the topic can be found here
http://www.nhforge.org/doc/nh/en/index.html. search for
"ICurrentSessionContext" (section 2.3.)

using an IoC container and HTTP module.

1. begin request: resolve factory, open session and bind to current
context. (manage transaction here as well)
2. inject ISession as a dependency on my controllers and services. IoC
containers usually have way to override how/where an object is
resolved. with castle i use either a factory method to
ISessionFactory.GetCurrentSessionContext(); or a SubDependencyResolver
if I'm using more than 1 session factory.
3. end request: resolve factory, unbind session from context. dispose.



On Nov 3, 2:10 am, Tuna Toksoz <[email protected]> wrote:
> in a web environment, what is done in NH Facility is that the session is
> opened at the beginning of the http request, stored in web session. Atthe
> end of the request, it is committer and disposed. Using this logic allows
> you to have lazy loading working pretty easily. It comes with downsides,
> though.
>
> Tuna Toksöz
> Eternal sunshine of the open source mind.
>
> http://devlicio.us/blogs/tuna_toksozhttp://tunatoksoz.comhttp://twitter.com/tehlike
>
> On Tue, Nov 3, 2009 at 8:43 AM, Shawn Hinsey <[email protected]> wrote:
>
> > I'm having a bit of trouble understanding exactly how session
> > management works when using the NH facility in an ASP.NET MVC
> > environment, particularly when it comes to lazy loading. I'm not sure
> > if the pattern in the documentation of disposing the session inside of
> > a dao/repository method is the best way to go or if there is another
> > approach I should be using.
>
> > Can anyone point me at a good resource? I haven't had much luck
> > googling. I took a look at S#arp Architecture but I wasn't really sure
> > where to start, so a pointer to a source file in their repo would also
> > be appreciated.
>
> > Thanks,
> > Shawn
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to