MySql.Data.MySqlClient.MySqlDataAdapter.OpenConnectionIfClosed C# (CSharp) Метод

OpenConnectionIfClosed() приватный Метод

Open connection if it was closed. Necessary to workaround "connection must be open and valid" error with batched updates.
private OpenConnectionIfClosed ( DataRowState state, List openedConnections ) : void
state DataRowState Row state
openedConnections List list of opened connections /// If connection is opened by this function, the list is updated ///
Результат void
        private void OpenConnectionIfClosed(DataRowState state,
            List<MySqlConnection> openedConnections)
        {
            MySqlCommand cmd = null;
            switch (state)
            {
                case DataRowState.Added:
                    cmd = InsertCommand;
                    break;
                case DataRowState.Deleted:
                    cmd = DeleteCommand;
                    break;
                case DataRowState.Modified:
                    cmd = UpdateCommand;
                    break;
                default:
                    return;
            }

            if (cmd != null && cmd.Connection != null &&
                cmd.Connection.connectionState == ConnectionState.Closed)
            {
                cmd.Connection.Open();
                openedConnections.Add(cmd.Connection);
            }
        }