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();
}
}
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();
}
}
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.