-
Notifications
You must be signed in to change notification settings - Fork 8
Transactions
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.