views:

11

answers:

0

Hi,

Suppose say I have a main function (or in the code behind) In this function, the TransactionScope is say ReadCommitted

This main function calls 3 other functions. All these three functions, do a DB operation.

The first function increments a sequence number (not auto increment). So, it has its own TransactionScope with isolation level as Serializable. [i.e. the value will be fetched from DB. Incremented by 1 and then updated again. So, no other process should even read the value selected by the current transaction].

The second and third function also have some DB operations.

Now, if the second/third DB call fails for some reason, then the dispose on the root TransactionScope (ReadCommitted) would be called which would rollback the changes made in function 2 and 3.

But what about the changes made by function 1. Since it had its own TransactionScope (Serializable), it would not be rolled back. Correct?

So, How should one handle this? The sequence number should not be incremented if the functions - 2 / 3 are gonna fail and not use it at all ultimately.

Also, can this kind of scenarios be designed in a different and much cleaner way? Or using Serializable for the function 1 is the best way.

Thanks!