You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Long Le edited this page Sep 20, 2017
·
3 revisions
Built in transaction handling in UnitOfWork
LinqPad Example
varproductRepository=newRepository<Product>(this);varproduct2=awaitproductRepository.FindAsync(7);product2.Dump();// Begin transactionunitOfWork.BeginTransaction();try{product2.ProductName="Chai4";product2.ObjectState=ObjectState.Modified;// always set the ObjectState// <Do other transactions here>productRepository.Update(product2);varchanges=awaitunitOfWork.SaveChangesAsync();changes.Dump("changes");// Commit TransactionunitOfWork.Commit();}catch{// Rollback transactionunitOfWork.Rollback();}product2=awaitproductRepository.FindAsync(7);product2.Dump();