gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 05:37:00 27 4
gpt4 key购买 nike

根据这篇文章 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) 以下代码默认为Serializable(覆盖数据库默认)
        using (TransactionScope transaction = new TransactionScope())
{

}

B) 以下代码默认为 ReadCommitted with Snapshot Isolation(而不仅仅是普通的 ReadCommitted)
        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) 对于该事务,隔离级别将仅为 ReadCommitted。对于快照,您需要

  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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com