查看它,我验证了例如值 o "myInt"在以下场景中不会回滚
int myInt = 10;
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
{
myInt=20;
Transaction t = Transaction.Current;
t.Rollback();
}
所以它让我思考“TransactionScope 是否只回滚与数据库相关的事件?或者还有其他事务可以管理而我不知道这些?”
最佳答案
当前事务仅影响称为资源管理器的特定对象。这些对象必须实现特定的接口(interface)才能参与事务。 ADO.NET SqlConnection 对象就是一个例子。创建一个用作“事务内存”的对象并不困难。这些对象称为 volatile 资源管理器。一个简单的例子是 here 。
关于c# - TransactionScope 的真正作用是什么,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15278963/