Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rollback Inserts/Updates/Deletes in linq pad?

I found this article about how to insert, update and delete using linq pad but it mentions nothing about rolling back anything.

Is it possible to rollback in linqpad?

like image 473
chobo2 Avatar asked Jun 20 '12 18:06

chobo2


1 Answers

Yes. You can do:

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.
}
like image 54
sblom Avatar answered Nov 15 '22 17:11

sblom