The code I gave is probably wrong since it does not use the current
session I think. (I have moved on from using activerecord sessions and
now just use AR for mapping,config and handle nhibernate sessions
directly)

Anyway see this blog post I just found:
http://www.kenegozi.com/Blog/2008/02/28/executing-plain-ol-sql-in-activerecord-transaction.aspx

~G

On Wed, Sep 2, 2009 at 12:36 PM, the.wizard<[email protected]> wrote:
>
> Hello Gerdus,
> Thank you for replying my post. I still don't understand what you are
> explain in your post, please explain it more detail.
> My goal is to save a data using active record object and execute a dml
> stored procedure in one db transaction.
> I have create a method that accept ISession object from parameter,
> then retrieve the command object from the ISession object. After that
> the command object will be use with ADO.NET to execute a dml stored
> procedure (using executenonquery method).
> Then I create a transactionscope just like you explain, but then I can
> get the session object from this transactionscope object. It has a
> GetSession method, but it need one parameter, a key that is an object
> type which I don't know what should I put for get it working. Have
> tried a lot but all failed getting an exception.
> Please help me, thanks a lot.
> Regards,
> the.wizard
>
> On 2 Sep, 13:50, Gerdus van Zyl <[email protected]> wrote:
>> I think you need to create a transactionscope yourself like:
>> TransactionScope transaction = new TransactionScope();
>> then you can use and pass it around as you like. Or what am I missing?
>>
>> And then you need a function like this to get the database connection
>> and enlist it in the transaction:
>>     Public Function getSQLCommand() As IDbCommand
>>         Dim sess As ISession
>>         'activerecord kry session wat connection bevat
>>         sess = 
>> ActiveRecordMediator.GetSessionFactoryHolder().CreateSession(GetType(Active­RecordBase))
>>
>>         'kry connnection vanaf activerecord session en create command
>>         Dim com As IDbCommand = sess.Connection.CreateCommand()
>>         If sess.Transaction.IsActive Then
>>             sess.Transaction.Enlist(com)
>>         End If
>>
>>         Return com
>>     End Function
>>
>> ~Gerdus
>>
>>
>>
>> On Wed, Sep 2, 2009 at 3:46 AM, the.wizard<[email protected]> wrote:
>>
>> > Hi everyone,
>> > Does anyone know how to get the session object in castle active record
>> > when doing a transaction? I want to perform a transaction that consist
>> > of a direct save using Castle Active Record object, and using a stored
>> > procedure, and I need the session object to pass it to my method that
>> > execute my stored procedure.
>> > Please help me, I have already frustated with this problem, have been
>> > looking all over internet, but can't find one to solve this problem.
>> > Really thanks a lot.
>>
>> > Regards.- Sembunyikan teks kutipan -
>>
>> - Perlihatkan teks kutipan -
> >
>

--~--~---------~--~----~------------~-------~--~----~
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