The simplest way to use ISession from ActiveRecordMediator is a bit verbose, it's the Execute method where you can pass a delegate and an arbitrary object instance
I've a wrapper code here http://code.google.com/p/smoothdev/source/browse/src/classlibraries/smoothdev.Data.ActiveRecordIntegration/smoothdev.Data.ActiveRecordIntegration.cobra that's looks like this: class ActiveRecordHelper<of T> where T must be class implements IActiveRecordHelper<of T> """Helps with common ActiveRecordMediator manipulations without relying on the static class""" def perform(action as Action<of ISession>) ActiveRecordMediator.execute(T.getType, do(session as ISession?, useless as Object?), nil) action(session) return nil def perform<of TReturnType>(functor as Func<of ISession, TReturnType>) as TReturnType result = ActiveRecordMediator.execute(T.getType, do(session as ISession?, useless as Object?), nil) to TReturnType return functor(session) return result On Aug 5, 1:49 am, chitech <[email protected]> wrote: > It's just what we want. We want to use the same transaction from the > NH calls so when SP calls is executed it will not be locked by the > transaction open by NH > > How can we get the connection by ActiveRecord. Something like this: > > ActiveRecordMediator.GetSessionFactoryHolder().GetSessionFactory(typeof(Act > iveRecordBase)).GetCurrentSession().Connection > > On Aug 5, 10:33 am, Gauthier Segay <[email protected]> wrote: > > > > > Hello Chitech > > > if you want to use the same connection, you can use > > ISession.Connection, your statement should be executed in the same > > transaction as the session is operating in. > > > I'm not sure how it's behaving with the underlying ADO.NET provider > > you are using, but I remember calling oracle SP (the deprecated ms > > provider one) using that handle to IDbConnection > > > Let us know what you find out or I misunderstood the problem. > > > On Aug 4, 2:46 pm, chitech <[email protected]> wrote: > > > > Alo > > > > We have alot of SP and now we want to only using NHibernate/ > > > Activerecord. > > > The SessionScope which create a implicit NHibernate Transaction > > > typically looks like this: > > > > NHibernate call1 -> NHibernate call2 -> SP call1 > > > > The database isolation level is set to Read Committed. And SP is > > > executed with its own connection (total separated from NHibernate) > > > If NHibernate call1 use table A and SP call1 also use table A we will > > > have a problem because table A is locked by NHibernate transaction. > > > I think one way to solve this is to commit the transaction before SP > > > call1 by using TransactionScope. This change have to done all places > > > with this combination > > > I am looking for at more generic solution. How about using the > > > IDBConnection from NHibernate session to execute the SP call1. Will > > > this solve the problem? > > > > Thx in advance -- 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.
