using SqlSugar; using System; using System.ComponentModel.DataAnnotations.Schema; namespace WCS.Entity { /// /// 实体类通用基础类 /// [Serializable] public abstract class OBJ { /// /// ID /// [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "ID")] [Column(Order = 0)] public virtual int ID { get; set; } /// /// 是否可用 /// [SugarColumn(ColumnDescription = "是否可用")] public bool ENABLED { get; set; } = true; /// /// 更新用户 /// 仅记录用户ID /// [SugarColumn(ColumnDescription = "更新用户", Length = 50)] public string UPDATEUSER { get; set; } /// /// 更新时间 /// [SugarColumn(ColumnDescription = "更新时间")] public DateTime UPDATETIME { get; set; } = DateTime.Now; /// /// 版本号 /// [SugarColumn(ColumnDescription = "版本号", ColumnDataType = "timestamp", IsNullable = true, IsOnlyIgnoreInsert = true, IsOnlyIgnoreUpdate = true)] public byte[] VER { get; set; } /// /// /// /// /// public T Copy() where T : OBJ { var instance = Activator.CreateInstance(); foreach (var property in GetType().GetProperties()) { var obj = property.GetValue(this); typeof(T).GetProperty(property.Name)!.SetValue(instance, obj); } return instance; } } }