private void BuildCache(bool closeConnection) { SqliteCommand sourceCommand = SourceCommand; if (sourceCommand == null) { throw new InvalidOperationException("The DataAdapter.SelectCommand property needs to be initialized."); } SqliteConnection connection = sourceCommand.Connection as SqliteConnection; if (connection == null) { throw new InvalidOperationException("The DataAdapter.SelectCommand.Connection property needs to be initialized."); } if (_schemaTable == null) { if (connection.State == ConnectionState.Open) { closeConnection = false; } else { connection.Open(); } SqliteDataReader reader = sourceCommand.ExecuteReader(CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo); _schemaTable = reader.GetSchemaTable(); reader.Close(); if (closeConnection) { connection.Close(); } BuildInformation(_schemaTable); } }