Exemple #1
0
        public virtual void GenerateColumn(DBTable table)
        {
            if (!string.IsNullOrEmpty(GroupName) && table.ColumnGroups[GroupName] == null)
            {
                var cgroup = new DBColumnGroup(GroupName);
                table.ColumnGroups.Add(cgroup);
            }
            Column = table.Columns[ColumnName];
            if (Column == null)
            {
                Column = CreateColumn(ColumnName);
            }
            if (Column.DisplayName.Equals(Column.Name, StringComparison.Ordinal) ||
                (Column.DisplayName.Equals(PropertyInfo.Name, StringComparison.Ordinal) &&
                 ReferencePropertyInfo != null))
            {
                Column.DisplayName = DisplayName;
            }

            if (Attribute.DBDataType != DBDataType.None)
            {
                Column.DBDataType = Attribute.DBDataType;
            }
            Column.DataType              = GetDataType();
            Column.Size                  = Attribute.Size;
            Column.Scale                 = Attribute.Scale;
            Column.ColumnType            = Attribute.ColumnType;
            Column.Keys                  = Attribute.Keys;
            Column.Culture               = Culture;
            Column.GroupName             = GroupName;
            Column.Property              = PropertyName;
            Column.PropertyInfo          = PropertyInfo;
            Column.ReferencePropertyInfo = ReferencePropertyInfo;
            Column.DefaultValues         = DefaultValues;
            if (DefaultValues != null && DefaultValues.TryGetValue(PropertyInfo.DeclaringType, out var defaultValue))
            {
                Column.DefaultValue = defaultValue;
            }

            if (!table.Columns.Contains(Column.Name))
            {
                table.Columns.Add(Column);
            }
        }
Exemple #2
0
 public IEnumerable <DBColumn> GetByGroup(DBColumnGroup group)
 {
     return(GetByGroup(group.Name));
 }