【发布时间】:2020-05-19 10:59:18
【问题描述】:
如果 context.savechanges() 失败,事务数据库状态和事务状态会是什么。我可以重复使用相同的事务但创建一个新的上下文吗?
// Should the retry be at this level in case saveChanges() fail.
using(var transaction = new TransactionScope())
{
// retry at this level in case saveChanges() fail. Use the ambient transaction?
using(var context = new DbContext)
{
//do some update and encounter exception (e.g., concurrency exception.)
context.saveChanges();
}
transaction.Complete();
}
【问题讨论】:
标签: c# entity-framework transactionscope savechanges