Exemplo n.º 1
0
 /// <summary>
 /// 检查是否连接
 /// </summary>
 /// <returns></returns>
 private bool IsConnection()
 {
     if (_conn == null)
     {
         return(false);
     }
     ConnectionState[] conn_state_arr = new ConnectionState[] { ConnectionState.Executing, ConnectionState.Fetching, ConnectionState.Open };
     return(conn_state_arr.Any(a => a == _conn.State));
 }
Exemplo n.º 2
0
        IDbHelper IDbHelper.Open()
        {
            if (_conn == null)
            {
                _conn = DBFactory.Get(_db_config);
                _conn.Open();
                return(this);
            }

            ConnectionState[] conn_state_arr = new ConnectionState[] { ConnectionState.Broken, ConnectionState.Closed };
            if (conn_state_arr.Any(a => a == _conn.State))
            {
                _conn.Close();
                _conn.Dispose();
                _conn = DBFactory.Get(_db_config);
                _conn.Open();
            }

            return(this);
        }