我需要更新多個更新語句,但都應該對原子性工作,即更新全有或全無。許多更新語句在實體框架
在互聯網和其他SO問題我已經找到了如何使用交易,但我沒有找到任何人說,要在一個交易中更新多個語句。 見下面三個更新語句,目前還不能下交易
/// this are my update calls.
var report = reportRepository.Update(reportModel);
var book = bookRepository.Update(bookModel);
var mobile = mobileRepository.Update(mobileModel);
// each Update method for all repository will looks like
public returnModel Update(someModel model)
{
// assign values from model to entity
Context.ObjectStateManager.ChangeObjectState(entity,System.Data.EntityState.Modified)
Context.SaveChanges();
}
是我說的這種方式。 .. –