chobo2
chobo2

Reputation: 85835

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?

Upvotes: 11

Views: 3086

Answers (1)

sblom
sblom

Reputation: 27353

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.
}

Upvotes: 15

Related Questions