gpt4 book ai didi

c# - 在 SQL 中更改隔离级别时的 SqlConnection 行为

转载 作者:行者123 更新时间:2023-11-30 17:45:39 25 4
gpt4 key购买 nike

根据http://msdn.microsoft.com/en-nz/library/ms173763.aspx的备注部分:

Only one of the isolation level options can be set at a time, and it remains set for that connection until it is explicitly changed.

并根据http://msdn.microsoft.com/en-us/library/8xx3tyca(v=vs.110).aspx

To minimize the cost of opening connections, ADO.NET uses an optimization technique called connection pooling.

这是否意味着如果 ISOLATION LEVEL 在存储过程中发生更改,它会在下一次使用连接时转移到其他人?例如

var con1 = new SqlConnection("<THE CONNECTION STRING>"); 

// ...call stored procedure altering isolation level with:
// SET TRANSACTION ISOLATION LEVEL SNAPSHOT

con1.Close();

var con2 = new SqlConnection("<THE CONNECTION STRING>");
// ... will this connection potentially have the altered isolation level?

编辑:是否有一种简单的方法来检查查询中使用的隔离级别?

最佳答案

A 部分...

没有。

来自docs ...

If you issue SET TRANSACTION ISOLATION LEVEL in a stored procedure or trigger, when the object returns control the isolation level is reset to the level in effect when the object was invoked. For example, if you set REPEATABLE READ in a batch, and the batch then calls a stored procedure that sets the isolation level to SERIALIZABLE, the isolation level setting reverts to REPEATABLE READ when the stored procedure returns control to the batc

关于c# - 在 SQL 中更改隔离级别时的 SqlConnection 行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27220991/

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