[Transactional(TransactionalTypes.TransactionScope)]

[Transactional(TransactionalTypes.TransactionScope)]

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


Vinodonly posted on Tuesday, August 10, 2010

I just noticed that

[

 

Transactional(TransactionalTypes.TransactionScope)] has stopped working.. It is saving parent even if the child is throwing error (custom error)..

My methods are marked with proper attribute i.e.

 

[

 

Transactional(TransactionalTypes.TransactionScope)]

 

 

 

protected override void DataPortal_Update()

and child is updated via :-

FieldManager.UpdateChildren(

 

this);

with nothing mentioned in child collection...

Is it anything to do with the way connection is created bcos i'm not using csla connection facility..

Vinodonly replied on Wednesday, August 11, 2010

can anybody help on this..

RockfordLhotka replied on Wednesday, August 11, 2010

I just made sure the TransactionScope unit test code is working, and it runs fine.

It doesn't matter if you use the Csla.Data helpers. If you have the Transactional attribute on your root object's data methods, all data access in that root or its child objects will be wrapped in a TransactionScope.

If an exception bubbles up from any of that code, that'll cause a rollback. The exception needs to flow back to the client of course.

TransactionScope only works with SQL Server (2005 and higher iirc).

If you open more than one connection to the database that'll cause .NET to use the Distributed Transaction Coordinator (DTC) to manage a distributed transaction. This usually causes an exception because the DTC is turned off by default. I've never tested to see if TransactionScope does the correct thing when it hits this condition (fails to access DTC) - but I assume Microsoft has tested that scenario.

Vinodonly replied on Thursday, August 12, 2010

server is 2005 only. and there are no err msgs from DTC..

unfortunately the problem is still there.. can you guide me on what other things i can check to rectify this issue.

FYI.. i'm using following in my connection string to ensure that dtc is not turned on.. do u think this makes any difference..

Enlist=false

RockfordLhotka replied on Thursday, August 12, 2010

I suspect you are telling the connection to enlist in no transactions, so yes, I think that makes a difference Smile

You can't have transactional protection if you are explicitly not in a transaction.

Vinodonly replied on Friday, August 13, 2010

although my question is answered.. i hv a similar query on the same line, which is actually not related with csla..

i made this setting thinking that it will stop the connection from going in DTC mode.. can you pls advs on how we can do that..

tmg4340 replied on Friday, August 13, 2010

The DTC kicks in whenever you enlist more than one resource in a transaction.  From a database perspective, that's any time you open more than one connection to the database and associate it with your TransactionScope - even if you use the same connection string.  That's the main purpose of the database connection manager in CSLA - it lets you re-use an existing (and already open) connection so that the DTC doesn't kick in.

HTH

- Scott

Copyright (c) Marimer LLC