using System; namespace Easy4net.CustomAttributes { /// /// 数据库主键字段特性 /// [AttributeUsage(AttributeTargets.Field|AttributeTargets.Property, AllowMultiple = false, Inherited = false)] public class IdAttribute : Attribute { /// /// 主键字段名 /// private string _Name = string.Empty; /// /// 主键字段名 /// public string Name { get { return this._Name; } set { this._Name = value; } } /// /// 主键字段生成方式,参考GenerationType定义 /// public int Strategy { get; set; } /// /// 创建一个默认的主键特性,字段生成方式为自动增长型 /// public IdAttribute() { this.Strategy = GenerationType.INDENTITY; } /// /// 创建一个制定字段名的主键特性,字段生成方式为自动增长型 /// /// 主键字段名 public IdAttribute(string aName) : this() { this.Name = aName; } } }