entity-framework - Entity Framework 事务和sql azure默认隔离级别

标签 entity-framework entity-framework-4 azure-sql-database transactionscope isolation-level

根据这篇文章http://social.technet.microsoft.com/wiki/contents/articles/handling-transactions-in-sql-azure.aspx

SQL Azure default database wide setting is to enable read committed 
snapshot isolation (RCSI) 

我的假设是否正确:

A) 以下代码默认为可序列化(覆盖数据库默认值)

        using (TransactionScope transaction = new TransactionScope())
        {                                                               

        }

B) 以下代码默认为带有快照隔离的 ReadCommissed(而不仅仅是普通的 ReadCommited)

        TransactionOptions options = new TransactionOptions();
        options.Timeout = TimeSpan.FromMinutes(1);
        options.IsolationLevel = IsolationLevel.ReadCommitted;

        using (TransactionScope transaction = new 
          TransactionScope(TransactionScopeOption.Required, options))
        {                                                               

        }

最佳答案

a) 是的。默认情况下,隔离级别为可串行化。 http://msdn.microsoft.com/en-us/library/ms172152(v=vs.90).aspx

b) 对于该事务,隔离级别将仅为 ReadCommissed。对于快照,您需要

  options.IsolationLevel = IsolationLevel.Snapshot;

http://msdn.microsoft.com/en-us/library/system.data.isolationlevel.aspx

关于entity-framework - Entity Framework 事务和sql azure默认隔离级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11796937/

相关文章:

sql-server - 实体命令执行异常 : Azure SQL with Entity Framework slow and rejecting requests

entity-framework-4 - Entity Framework 4 CTP 5 自引用多对多

c# - 为什么 Entity Framework 不让 SQL Server 生成主键?

azure - 使用 PySpark 从 Azure HDInsight 检索数据

azure - 从付费 Azure SQL 数据库恢复为免费

c# - Entity Framework 6 的多对多通用更新方法

entity-framework - 将项目从 .NET 4.0 升级到 .NET 4.5 后失败 => 找不到类型或命名空间名称 'MaxLength'/'Column'

c# - Entity Framework : how to map multiple tables with different keys to one entity?

entity-framework-4 - 指定的 LINQ 表达式包含对与不同上下文关联的查询的引用

azure - 'Allow Azure services and resources to access this server' 创建的防火墙规则的名称是什么