TransactionScope Complete()在退出USING语句之前不提交事务 [英] TransactionScope Complete() doesn't commit the transaction before exiting the USING statement

查看:55
本文介绍了TransactionScope Complete()在退出USING语句之前不提交事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在经历这种奇怪的行为,即仅在使用 using 退出时才提交事务,而不是在调用 scope.Complete();

I am experiencing this weird behavior where the transaction gets committed only when the using exits and not when calling scope.Complete();

using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
       {
        scope.Complete();
           // data still doesn't show in db
       }
       // now shows in db

我如何在退出 using 语句之前提交事务?

How do I commit the transaction before exiting the using statement?

推荐答案

"rel ="noreferrer">文档:

from the documentation:

如果TransactionScope对象创建了事务,则资源管理器之间的实际提交工作发生在 End Using 语句中.

因此,看起来您不能真正地在using语句结束之前提交事务.

So it doesn't look like you can truly commit the transaction before the using statement end.

这篇关于TransactionScope Complete()在退出USING语句之前不提交事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆