using System; using System.ComponentModel.DataAnnotations; namespace CK.SCP.Models.Attributes { /// /// 列来源属于 /// [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] public class ColumnSource : Attribute { /// /// /// 列来源。ENUM:枚举数据源.TABLE表数据源(外键关系) /// 来源数据源类型 /// /// sourceType为TABLE时,columName是对应表中的列名 /// columnNames[0]: ValueMember ,colums[1]:DisplayMember public ColumnSource(ColumnSourceType sourceType, Type typeName, string[] columnNames = null, string selector = null) { SourceType = sourceType; TypeName = typeName; ColumnNames = columnNames; Selector = selector; } public ColumnSourceType SourceType { get; } /// 获取或设置属性映射到的列的从零开始的顺序。 /// 列的顺序。 public Type TypeName { get; } /// 获取或设置该属性映射到的列的数据库提供程序特定的数据类型。 /// 属性将映射到的列的数据库提供程序特定数据类型。 [StringLength(50)] public string[] ColumnNames { get; } [StringLength(50)] public string Selector { get; set; } } public enum ColumnSourceType { /// /// 枚举数据源 /// ENUM = 1, /// /// 表数据源 /// TABLE = 2, /// /// bool类型 /// Boolean = 4 } }