private void OnExecute(Document document) { ResultSets.Clear(); try { IEnumerable <DataTable> results; if (string.IsNullOrEmpty(ActiveDocumentSelectedText)) { results = _sqliteService.ExecuteQuery(_activeDocument.Text, _activeDocument.DatabasePath); } else { results = _sqliteService.ExecuteQuery(ActiveDocumentSelectedText, _activeDocument.DatabasePath); } foreach (DataTable table in results) { ResultSets.Add(table); } } catch (Exception ex) { WpfMessageBox.ShowDialog("Execution Error", ex.Message, MessageBoxButton.OK, MessageIcon.Error); } }