Skip to content
Philippe Leybaert edited this page Aug 10, 2016 · 4 revisions

Transactions can be implemented by creating a Transaction object and calling Commit() or Rollback() on the object:

using (var transaction = new Transaction(dbContext))
{
   dbContext.Insert(new Product() {...});

   transaction.Commit();
}
using (var transaction = new Transaction(dbContext))
{
   dbContext.Insert(new Product() {...});

   transaction.Rollback();
}

If Commit() isn't called before the transaction object is disposed, an implicit rollback is performed.

Clone this wiki locally