SqlTransaction togehter with LLBLGen transaction

Posts   
 
    
moebius
User
Posts: 8
Joined: 01-Jul-2005
# Posted on: 19-Jul-2005 17:52:30   

Is it possible to place SqlCommands and actions on Entities (fetch, save, delete) into the the same SqlTransaction? We already have some DAO classes wich we would like to reuse, and there are some unnormalized tables wich are not so easy to use as entities. And last but not least its always good if one can fall back just in case.

I noticed the PhysicalTransaction property, would the following code be sufficent?

SqlConnection con = createConnection(); con.Open(); SqlTransaction trans = con.BeginTransaction();

Transaction llbglTrans = new Transaction(IsolationLevel.ReadCommitted, "dostuff"); llbglTrans.ConnectionToUse = con; llbglTrans.PhysicalTransaction = trans;

// do stuff

llbglTrans.Commit(); con.Close();

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 20-Jul-2005 11:59:07   

moebius wrote:

Is it possible to place SqlCommands and actions on Entities (fetch, save, delete) into the the same SqlTransaction? We already have some DAO classes wich we would like to reuse, and there are some unnormalized tables wich are not so easy to use as entities. And last but not least its always good if one can fall back just in case.

I noticed the PhysicalTransaction property, would the following code be sufficent?

SqlConnection con = createConnection(); con.Open(); SqlTransaction trans = con.BeginTransaction();

Transaction llbglTrans = new Transaction(IsolationLevel.ReadCommitted, "dostuff"); llbglTrans.ConnectionToUse = con; llbglTrans.PhysicalTransaction = trans;

// do stuff llbglTrans.Commit(); con.Close();

Do it the other way around: - create a new Transaction object. This object then controls the transaction - grab the connection of the Transaction object using the 'ConnectionToUse' property and the transaction using the PhysicalTransaction property. - use these 2 objects together with your other DAO objects.

Frans Bouma | Lead developer LLBLGen Pro
moebius
User
Posts: 8
Joined: 01-Jul-2005
# Posted on: 21-Jul-2005 09:42:01   

Argh, should have been my idea. Interesting how one is focused in one way only. Thanks.