FYI, you can see how I did this for the AltOxite sample for FubuMVC: http://is.gd/fxaT [Link to GoogleCode repo browser] Look at line 36/37. See how the Unit of Work is cached by Hybrid? The NHibernateUnitOfWork has a c'tor dependency upon ISessionSource which is configured on line 29. You'll note how I set up the session source with the persistence model right there in the configuration. An example of an ISessionSourceConfiguration is found here: http://is.gd/fxcI [Link to SQLiteSessionSourceConfiguration source] -c
________________________________ From: fluent-nhibernate@googlegroups.com on behalf of Chad Myers Sent: Mon 1/12/2009 10:39 AM To: fluent-nhibernate@googlegroups.com Subject: RE: [fluent-nhib] Re: Repository StructureMap has a CacheBy(InstanceScope.Hybrid) which is per-HttpRequest or per-Thread depending on whether you're running in an ASP.NET context or not. The first time an ISession is requested on a request, SMap will go through the process of building the instance and then cache it in the request (HttpContext.Items) for you. Each additional request for an ISession instance on that request will result in that same instance. -c ________________________________ From: fluent-nhibernate@googlegroups.com on behalf of Andrew Stewart Sent: Mon 1/12/2009 9:27 AM To: fluent-nhibernate@googlegroups.com Subject: [fluent-nhib] Re: Repository I'm going to be quiet now, think I've already figured this out. You could do it via a facility in castle for example. Andy On Mon, Jan 12, 2009 at 2:54 PM, Andrew Stewart <andrew.stew...@i-nnovate.net> wrote: Hi Just out of interest how could you configure the IOC to send in a copy of ISession as personally I tend to open a session per HttpRequest? Andy On Sun, Jan 11, 2009 at 8:40 PM, Stuart Campbell <stuart.campbe...@gmail.com> wrote: Yeah I wasn't completely happy with the inheritance approach. Although I also didn't want to use service location to get hold of the session everywhere. But I suppose if I get the container to inject the ISession instead of ISessionSource then I can keep a reference to it in any Repository subclass that needs to do anything special. Thanks Stu On Sun, Jan 11, 2009 at 8:15 PM, Jeremy D. Miller <jeremydmil...@yahoo.com> wrote: The way we handle that was to make our Repository take in an ISession instead of the ISessionSource. Assuming that your IoC tool is set with the scoping correctly, we can simply consume the exact same ISession in another class that opens up special abilities. I vote down on opening up ISession on IRepository. That's just not good design, or absolutely necessary. Jeremy D. Miller The Shade Tree Developer <http://codebetter.com/blogs/jeremy.miller> jeremydmil...@yahoo.com ________________________________ From: Stuart Campbell <stuart.campbe...@gmail.com> To: fluent-nhibernate@googlegroups.com Sent: Sunday, January 11, 2009 1:53:38 PM Subject: [fluent-nhib] Repository Hi, I was wondering how many people are using FluentNHibernate.Framework.Repository in anger and if so, how you are handling custom queries. The reason I ask is because I'm deriving from Repository but finding that sometimes I need to use the ISession and it isn't really exposed. My repositories are injected with an ISessionSource and that doesn't expose the ISession either. So for now I have just made Repository._session protected in my FNH working copy. Would it be a good idea to make this change (or similar) in the trunk? Stu -- ================= I-nnovate Software - Bespoke Software Development, uk wirral. http://www.i-nnovate.net <http://www.i-nnovate.net/> -- ================= I-nnovate Software - Bespoke Software Development, uk wirral. http://www.i-nnovate.net <http://www.i-nnovate.net/> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to fluent-nhibernate@googlegroups.com To unsubscribe from this group, send email to fluent-nhibernate+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en -~----------~----~----~----~------~----~------~--~---
<<inline: winmail.dat>>