Sql Azure中的TransactionScope() [英] TransactionScope() in Sql Azure

查看:138
本文介绍了Sql Azure中的TransactionScope()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行插入时,Sql Azure是否支持使用TransactionScope()?下面是我要执行的操作的代码段.

Does Sql Azure support using TransactionScope() when performing inserts? Below is a code snippet of what I am trying to do.

using (var tx = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions() { IsolationLevel = IsolationLevel.ReadCommitted }))
            {
                using (var db = MyDataContext.GetDataContext()) 
                {
                    try
                    {
                        MyObject myObject =  new MyObject()
                       {
                         SomeString = "Monday"

                       };
                        db.MyObjects.InsertOnSubmit(myObject);
                        db.SubmitChanges();
                        tx.Complete();
                    }
                    catch (Exception e)
                    {
                    }
                 }
             }

推荐答案

使用Azure SQL数据库进行分布式事务的快速更新:几天前,我们引入了对Azure SQL数据库中分布式事务的支持.点亮该功能的功能称为弹性数据库事务.它重点介绍使用.NET分布式事务API(例如TransactionScope)的方案.一旦安装了新的4.NET版本的.NET框架,这些API就开始针对Azure SQL数据库工作.您可以在此处找到有关如何入门的更多信息:

Quick update on distributed transactions with Azure SQL Database: A couple of days ago, we introduced support for distributed transactions in Azure SQL Database. The feature that lights up the capability is called elastic database transactions. It focuses on scenarios using the .NET distributed transaction APIs such as TransactionScope. These APIs start working against Azure SQL Database once you installed the new 4.6.1 release of the .NET framework. You can find more information about how to get started here: https://azure.microsoft.com/en-us/documentation/articles/sql-database-elastic-transactions-overview/.

请尝试一下!

这篇关于Sql Azure中的TransactionScope()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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