VB.NET - 隐和显式事务 [英] VB.NET - Implicit and Explicit Transactions

查看:188
本文介绍了VB.NET - 隐和显式事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是过明确的事务(的SqlTransaction)使用隐式交易(TransactionScope的)好处?

What are the benefits of using implicit transactions (TransactionScope) over explicit transactions (SQLTransaction)?

我花了一些时间来调查这一点,有很多的网站,说明两者之间的差异,这我明白如这一个: http://sqlserverpedia.com/wiki/Transaction_Overview ,而这一次:的named明确和放大器;隐式事务的。我明白了一个交易,即酸的性质。我也看了一下MSDN上的文档。

I have spent some time investigating this and there are lots of websites that explain the differences between the two, which I do understand e.g. this one: http://sqlserverpedia.com/wiki/Transaction_Overview, and this one: named explicit & implicit transactions. I understand the properties of a Transaction i.e. ACID. I have also looked at the documentation on MSDN.

我认为,隐性交易更灵活,更易于使用(因为回滚为你做了,交易不依赖于特定的连接)。我认为,明确的交易给你更多的例如控制当回滚。我想确认:一)我刚才所说的是否属实,b)是否有用来决定是否使用隐性或显性事务的任何标准

I believe that implicit transactions are more flexible and easier to use (because rollback is done for you and the transaction is not tied to a specific connection). I believe that explicit transactions give you more control e.g. when to rollback. I wanted to confirm: a) whether or not what I have said is true, b) Is there any criteria used to decide whether to use an implicit or explicit transaction.

在MSDN它说:强烈建议您使用更方便隐含的模式发展

On MSDN it says: "It is highly recommended that you use the easier implicit model for development"

推荐答案

明确的交易是过去的事情了。除非你有一个的很好的理由的不要使用他们,我想不出任何。 的TransactionScope 是去,实际上总是方式。

Explicit transactions are a thing of the past. Don't use them unless you have a really good reason, and I can't think of any. TransactionScope is the way to go, practically always.

不要担心DTC,的TransactionScope 是足够聪明,只使用DTC时,两种资源需要协调。如果您正在访问只有一个数据库,的TransactionScope 将是每一位快显式事务。

Don't worry about DTC, TransactionScope is smart enough to use the DTC only when two resources need to be coordinated. If you're accessing just one database, TransactionScope will be every bit as fast as explicit transactions.

这篇关于VB.NET - 隐和显式事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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