SqlConnection在事务中"登记"是什么意思?它只是意味着我在连接上执行的命令将参与事务吗?
如果是这样,在什么情况下SqlConnection会自动登记在环境TransactionScope事务中?
查看代码注释中的问题.我对每个问题的答案的猜测都在括号中的每个问题之后.
using (TransactionScope scope = new TransactionScope())
using (SqlConnection conn = ConnectToDB())
{
// Q1: Is connection automatically enlisted in transaction? (Yes?)
//
// Q2: If I open (and run commands on) a second connection now,
// with an identical connection string,
// what, if any, is the relationship of this second connection to the first?
//
// Q3: Will this second connection's automatic enlistment
// in the current transaction scope cause the transaction to …Run Code Online (Sandbox Code Playgroud)