Differences between transaction types?

Differences between transaction types?

Old forum URL: forums.lhotka.net/forums/t/3006.aspx


g18c posted on Friday, June 08, 2007

Hi, I’m currently learning CSLA and i have read good chunks of the CSLA book but it is very new to me still. I have read that performance can be enhanced for multiple inserts/updates etc for child objects in business lists by passing a SqlTransaction object in to the appropriate insert or update function. It mentioned this is a 'manual method'. Ok, so I’m happy with manual methods!

 

However I don’t fully understand the other transactions types. Apart from this 'manual ado.net transaction method', is it possible to get automated transactions to the database without additional code or is my understanding completely wrong? Any pointers as to the differences between transaction types (but in layman’s terms!) and their useage scenario would be great as the book in some cases is still steep for me. I'm guessing i need to look into System.Transactions as that is a completely new word to me, but some gentle pointers would be much appreciated.

 

Thanks,

 

Chris

ajj3085 replied on Friday, June 08, 2007

TransactionScope transactions are very easy with Csla.. you just decorate your DP_I or DP_U with the Transactional atribute and specify TS.

There are some limitations though; one is that you can only use one connection object to do all the updates.  You can't open another connection even if the connection string matches exactly.  Well you can, but if you do so the transaction will be promoted to a Distributed transaction and you have to have DTC running on both client and server. You'll also see a big performance hit.  If you need to rollback, you throw an exception.  Otherwise, its all handled automatically for you.

Also, I'm not sure how it works with anything other than Sql Server 2005. 

The other option is using an enterprise services transaction, which IIRC is the same thing as a distributed transaction.  That would require some setup I believe.. the details can be found here though.

g18c replied on Friday, June 08, 2007

Thanks very much for taking the time to reply. How would one access this connection from the insert or update dataportal procedures (is it a parameter, inside the business object itself or added when the transaction attribute is specified? From the book i could only see explicit access to local connections created within the procedures themself? Or am i barking up completly the wrong tree?!

Brian Criswell replied on Friday, June 08, 2007

You can pass it in the Update methods on your child objects like the book demonstrates.  You can also use ApplicationContext (which I believe the 2.1 PDF demonstrates).

Copyright (c) Marimer LLC