public ModelCommonStringStore GetColumns(string table) { ModelCommonStringStore models = new ModelCommonStringStore(); IModel model; if (SQLiteCheckImportedDB.Check(settings.Database) && table.Equals("MainData")) { string query = "SELECT ColumnName, ColumnAlias FROM 'ColumnNameAndAlias';"; using (DataTable dt = GetTable(query)) { if (dt?.Rows.Count > 0) { foreach (DataRow r in dt?.Rows) { model = new ModelCommon { Name = $"{r.Field<string>("ColumnName")}", Alias = $"{r.Field<string>("ColumnAlias")}" }; models.Add(model); } } } } else { DbSchema schemaDB = DbSchema.LoadDB(settings.Database); if (schemaDB?.Tables?.Count > 0) { foreach (var _table in schemaDB.Tables) { if (_table.Value.TableName.Equals(table)) { foreach (var column in _table.Value.Columns) { model = new ModelCommon { Name = column.ColumnName, Alias = column.ColumnName }; models.Add(model); } } } } } return(models); }
private void listBoxColumn_AddRemoveSelectedLine(string text) { if (!(string.IsNullOrWhiteSpace(text))) { if (columnDeleteStore?.GetItem(text) != null) { columnDeleteStore?.Remove(text); } else { columnDeleteStore.Add(new ModelCommon() { Name = text, Alias = text }); } } }
private async Task GetSample(string columnName) { ISQLConnectionSettings newSettings = currentSQLConnectionStore?.GetCurrent(); ModelCommonStringStore models = null; await Task.Run(() => models = SQLSelector.GetDataSample(newSettings, columnName)); if (models?.ToList()?.Count > 0) { sampleStore.Set(models); } else { sampleStore.Reset(); sampleStore.Add(new ModelCommon() { Name = $"В таблице данные отсутствует в столбце '{columnName}'" }); } }
static ModelCommonStringStore GetListForModelStore(SqlAbstractConnector sqlConnector, string query) { ModelCommonStringStore models = new ModelCommonStringStore(); IModel model; try { using DataTable dt = sqlConnector.GetTable(query); foreach (DataRow r in dt?.Rows) { model = new ModelCommon { Name = r[0].ToString(), Alias = r[0].ToString() }; models.Add(model); } dt?.Dispose(); } catch { } return(models); }