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);
        }
Beispiel #2
0
        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);
        }