Hi all
Im really struggling with NHibernate here. I'm trying to keep my DAL-assembly very generic, so that it works in a webcontext, in WCF and in WinForms / WPF. My problem here is the sessions.
Lazy-loading is good, and something I really want, but after the session which you loaded the object with is closed, you can't lazy-load anymore. This turns out to be a huge deal for me, since I don't know in which scope I should start / end my sessions.
I've seen a lot of people starting them on HttpContext.Begin and ending them on .End, but this is not feasable for me, since I don't want my assembly to link to System.Web or be bound to be called in a HttpContext.
Another option would be to just keep one session for the entire DAL-assembly lifecycle. What are some pros and cons onto this approach? The assembly will mainly work as a backend in a website, but also do some work for a WinForms application.
Any takers? :)
[EDIT] Another option for me would be to write my own lazy-loading proxy-collections, which in turn would open a new session and fetch whatever data the collection should contain. Any comments on this approach?