[英]TransactionScope Complete() doesn't commit the transaction before exiting the USING statement
I am experiencing this weird behavior where the transaction gets committed only when the using
exits and not when calling scope.Complete();
我遇到这种奇怪的行为,只有当
using
退出而不是在调用scope.Complete();
时才scope.Complete();
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
{
scope.Complete();
// data still doesn't show in db
}
// now shows in db
How do I commit the transaction before exiting the using
statement? 如何在退出
using
语句之前提交事务?
from the documentation : 从文件 :
The actual work of commit between the resources manager happens at the End Using statement if the TransactionScope object created the transaction.
如果TransactionScope对象创建了事务,则资源管理器之间的实际提交工作发生在End Using语句中。
So it doesn't look like you can truly commit the transaction before the using statement end. 因此,看起来您不能在using语句结束之前真正提交事务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.