Beispiel #1
0
        private void GetAttrList()
        {
            try
            {
                Attributes = new Dictionary <string, DBAttribute>();

                dynamic result = DB.Query(
                    "select (column_name) as Name, (data_type) as Type, (column_default) as DefaultValue, (is_nullable) as Nullable, (character_maximum_length) as Size" +
                    " from information_schema.columns" +
                    $" where table_name = '{Name}'");

                foreach (dynamic field in result)
                {
                    string name     = field.name;
                    string nullable = field.nullable;

                    Attributes.Add(name, new DBAttribute {
                        Default  = field.defaultvalue,
                        Name     = name,
                        Nullable = nullable.IsMatch("yes"),
                        Size     = field.size == null ? 0 : field.size,
                        Type     = DB.FromDBType(field.type)
                    });
                }
            }
            catch (Exception ex)
            {
                Logger.WriteToTrace($"Ошибка формирования атрибутов: {ex}", TraceMessageKind.Error);
                throw;
            }
        }