1
votes

In my Project, DAL Is WCF service .Net4.0. using database oracle 11g. I am using transaction scope in WCF(server side). I have to call more than one Stored procedure inside the method(operation contract) if any one sp failed, I need to rollback already executed sp. But rollback not happened. I am not used client side transaction flow.

I have placed sample code

public class Service : IService {

public bool Method1()
    {
        using (TransactionScope Scope1 = new TransactionScope())
        {
            Method2();
            Method3();
            Scope1.Complete();
        }
        return true;
    }

    public bool Method2()
    {
        using (TransactionScope Scope2 = new TransactionScope())
        {
            // Procedure call .....
            Scope2.Complete();
        }
        return true;
    }

    public bool Method3()
    {
        using (TransactionScope Scope3 = new TransactionScope())
        {
            // Procedure call .....
            Scope3.Complete();
        }
        return true;
    }

}

1
could you post your codeShiraz Bhaiji

1 Answers

1
votes

I don't see any reason why that wouldn't work as expected, the way you have your code laid out there.

However if you are using WCF, you might want to consider using the transaction flow stuff built in to WCF. You can wrap the entire WCF call into a single transaction that way, without manually creating and managing TransactionScopes. The WCF transaction flow can be set up to require a transaction at the service side, so WCF will start a transaction for you if the client doesn't pass one. This way you wouldn't have to edit your client at all. http://msdn.microsoft.com/en-us/library/ms751413.aspx