did anyone used TransactionScope when adding ojects to a list of objects? Something like:
using Transaction
{
try
{ var a = method();
list.add(a)
transaction.commit;
}
catch exception(Ex)
{
transaction.rollback();
}
}
Should work just fine ? Thanks!
TransactionScope
requires cooperation from anything that wants to be transacted. Database APIs usually cooperate and are willing to be transacted. None of the built-in data structures cares (or knows) about TransactionScope
so this will simply have no effect.
The catch+rollback is a common mistake, just delete that code.