TransactionScope does not rollback inside wcf service method

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
rayback2
Posts: 2
Joined: Tue 06 Mar 2012 07:49

TransactionScope does not rollback inside wcf service method

Post by rayback2 » Tue 06 Mar 2012 08:07

Hi,

I am facing a problem that drives me crazy for couple of days now, hoping someone can help me.
Here it is ;

I'm using EF4 with oracle database, using dotConnect for oracle from devart as provider.
I have wcf service method which calls DeleteCabinet method below;

Code: Select all

 public void DeleteCabinet(string pRID)
    {
    	using(TransactionScope tranScope = new TransactionScope())
    	{
    		DBUtils.DeleteCabinetAndShelves(pRecordId);
    		
    		//throw exception to test record not deleted
    		throw new Exception("xxx something has happened test xxx");
    		
    		tranScope.Complete();
    	}
    }
DBUtils.DeleteCabinetAndShelves looks like below;

Code: Select all

  public void DeleteCabinetAndShelves(string pRecordId)
    {
    	using(var context = new EdrmEntities())
    	{
    	    var cabinet = context.Cabinets.Include("Shelves").Single(p => p.RID == pCabinetRID);
    
    		//mark all cabinet shelves for deletion
    		if (cabinet.Shelves != null)
    		{
    			foreach (var tempShelf in cabinet.Shelves.ToList())
    			{
    				context.DeleteObject(tempShelf);
    			}
    		}
    
    		//mark cabinet for deletion
    		context.DeleteObject(cabinet);
    
    		//save 
    		context.SaveChanges();
    	}
    }
when I call DeleteCabinet from within my test project, not a wcf call but direct method call, it works OK. It throws exception ,and transaction is rolled back. Thus no record is deleted from DB as expected

The problem is that when I call service method (which calls DeleteCabinet) from a client, the exception is thrown , but the record IS deleted from db. Transaction does not roll back !

seems like calling wcf method does not roll back transaction, but it seems crazy ( at least to me), does anybody know the reason why this might be happening ?

Thanks in advance

P.S : I asked the question above on stackoverflow earlier, reposting it here again since I got no answer there (yet), and this forum seems more appropriate for dotconnect issues.

rayback2
Posts: 2
Joined: Tue 06 Mar 2012 07:49

answer

Post by rayback2 » Wed 07 Mar 2012 08:42

the issue turned out to be the connection string settings. the answer and comments leading to the answer can be reached on stackoverflow

Post Reply