K
kikapu
Hi to all folks,
i am trying to understand the use of System.Transactions in general and
TransactionScope particularly.
What am i allowed to do in a using statement that wraps a TransactionScope
object,
so this to be rollback in case of an exception or when i do not call
scope.complete ??
I mean, can i set an object's variables and then un-done these sets
automatically
when transaction rolls back ??
For example, the following code does not work, x.var remains 2 after the
suing statement,
even if i throw an exception after var set:
class Program
{
static void Main(string[] args)
{
X x = new X();
x.var = 1;
using (TransactionScope scope = new
TransactionScope(TransactionScopeOption.Suppress))
{
x.var = 2;
//scope.Complete();
}
Console.WriteLine(x.var);
}
}
class X
{
public int var;
}
}
I am sure that i am missing something here, can anyone help ??
Kikapu
i am trying to understand the use of System.Transactions in general and
TransactionScope particularly.
What am i allowed to do in a using statement that wraps a TransactionScope
object,
so this to be rollback in case of an exception or when i do not call
scope.complete ??
I mean, can i set an object's variables and then un-done these sets
automatically
when transaction rolls back ??
For example, the following code does not work, x.var remains 2 after the
suing statement,
even if i throw an exception after var set:
class Program
{
static void Main(string[] args)
{
X x = new X();
x.var = 1;
using (TransactionScope scope = new
TransactionScope(TransactionScopeOption.Suppress))
{
x.var = 2;
//scope.Complete();
}
Console.WriteLine(x.var);
}
}
class X
{
public int var;
}
}
I am sure that i am missing something here, can anyone help ??
Kikapu