在linq pad中回滚插入/更新/删除?

cho*_*bo2 5 linq rollback linqpad

我发现这篇文章关于如何使用linq pad插入,更新和删除,但它没有提到回滚任何内容.

是否可以在linqpad中回滚?

sbl*_*lom 8

是.你可以做:

using (TransactionScope scope = new TransactionScope()) {
  // Put the operations that you want to protect in a transaction here.

  if (you_want_to_commit) {
    scope.Complete();
  }
  // Otherwise, it'll roll back when you exit the using block.
}
Run Code Online (Sandbox Code Playgroud)