我有一个围绕一些功能的事务范围。这些函数每个都执行插入或更新的数据库调用。
using (var ts = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions()
{
IsolationLevel =
IsolationLevel.Serializable,
Timeout = new TimeSpan(0, 0, 15, 0)
}))
{
DoStuff(arg!, arg2);
ts.Complete(); //This had to be added to commit the changes for inserts (updates worked), otherwise data was being rolled back
}
随着ts.Complete();
插入和更新被提交到数据库,没有只有更新。有人可以解释为什么吗?