yes On Mon, Sep 21, 2009 at 7:20 PM, Martin Nilsson <[email protected]> wrote:
> Yes, that was the case. Thanks. > My other question regarding taking ISession as a ctor argument. Then all > those classes (queryobject, service and repository) needs to be transient? > > > On Sun, Sep 20, 2009 at 12:45 PM, Ayende Rahien <[email protected]> wrote: > >> You need to register the factory facility. >> >> >> On Sun, Sep 20, 2009 at 10:15 AM, Martin Nilsson <[email protected]>wrote: >> >>> Ok ok :) >>> >>> I changed to this instead: >>> Kernel.Register(Component.For<ISession>().LifeStyle.Transient.UsingFactoryMethod(() >>> => Kernel.Resolve<ISessionFactory>().GetCurrentSession())); >>> >>> but then I get error: >>> "Type NHibernate.ISession is abstract. >>> As such, it is not possible to instansiate it as implementation of >>> NHibernate.ISession service" >>> >>> My solution now is this (not causing the above error): >>> >>> ServiceClass: >>> ctor(IUnitOfWorkFactory unitOfWorkFactory) >>> >>> In ServiceMethod: >>> var session = unitOfWorkFactory.CurrentSession; >>> >>> Questions: >>> 1. Anyone knows why I get the above error? >>> 2. Is my other solution (using IUnitOfWorkFactory) better/ok then? >>> 3. You say that it's possible (better?) to take the ISession as a ctor >>> arg. Will that be a different one for each req if my service class is >>> singleton, although my session registration is transient? >>> >>> >>> On Fri, Sep 18, 2009 at 9:50 PM, Ayende Rahien <[email protected]>wrote: >>> >>>> This is HORRIBLE. >>>> You micro manage the session and remove from NH things like UoW, auto >>>> change tracking, persistence by reachability, etc. >>>> Sessions should be managed by request / context, not in methods. >>>> >>>> On Fri, Sep 18, 2009 at 4:25 PM, Martin Nilsson <[email protected]>wrote: >>>> >>>>> >>>>> ProductService: >>>>> public void Save(Product product) { >>>>> using(var session = ?.GetSession) >>>>> using(var tx = session.BeginTransaction()) >>>>> { >>>>> repository.Add(product); >>>>> tx.Commit(); >>>>> } >>>>> } >>>>> >>>>> >>>> >>>> >>> >>> >>> >> >> >> > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Rhino Tools Dev" 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/rhino-tools-dev?hl=en -~----------~----~----~----~------~----~------~--~---
