直到在C#中将事物连接起来为止,什么都不做的最佳方法

问题描述

| 我正在查看正在连接的应用程序之一中连接到数据库的代码,我看到了
 if (_dbConnection == null)
     _dbConnection = GetConnection();

 while (_dbConnection.State == ConnectionState.Connecting)
 {
     //Do Nothing until things are connected.
 }

 if (_dbConnection.State != ConnectionState.Open)
     _dbConnection.Open();

 var command = GetCommand(commandType);
 command.Connection = _dbConnection;
 return command;
while循环让我担心。在事物连接好之前,还有什么更好的方法吗? 编辑: 连接如下
private static IDbConnection GetConnection()
{
     return new SqlConnection(ConfigurationManager.ConnectionStrings[\"CoonectionStringName\"].ConnectionString);
}
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)