【发布时间】:2013-01-03 16:41:21
【问题描述】:
我有一个围绕一些功能的事务范围。这些函数每个都执行插入或更新的数据库调用。
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();,插入和更新被提交到数据库,而不仅仅是更新。有人可以解释一下原因吗?
【问题讨论】:
-
我也遇到了类似的问题,请问您是如何解决提交更改而不调用 Complete() 的问题的?
标签: c# .net transactions