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

时间:2012-06-20 18:38:41

标签: linq rollback linqpad

我发现this article关于如何使用linq pad插入,更新和删除它,但它没有提到回滚任何内容。

是否可以在linqpad中回滚?

1 个答案:

答案 0 :(得分: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.
}