Say I have 2 methods (A and B)
public void A()
{
using (var connection = Database.GetConnectionString())
using (var tran = new TransactionScope())
{
//do "A"
tran.Complete()
}
}
public void B()
{
using (var connection = Database.GetConnectionString())
using (var tran = new TransactionScope())
{
A(); //call "A"
//do "B"
tran.Complete()
}
}
As you can see, method B
need to call A
, but both A
and B
already has its own TransactionScope
, in this case, what's the correct way to pass the TransactionScope
?
My Expectation is when method A
is called, it will
-. BEGIN TRAN
-. DO "A"
-. COMMIT TRAN
when method B
is called, it will
-. BEGIN TRAN
-. DO "A"
-. DO "B"
-. COMMIT TRAN
Any help will be appreciated