OBJ.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.ComponentModel.DataAnnotations.Schema;
  4. using System.Reflection;
  5. namespace WCS.Entity
  6. {
  7. [Serializable]
  8. public abstract class OBJ
  9. {
  10. [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
  11. [Display(Name = "主键", Order = 0)]
  12. [Key]
  13. [Column(Order = 0)]
  14. public virtual int ID { get; set; }
  15. [Display(Name = "可用")]
  16. public bool ENABLED { get; set; } = true;
  17. [MaxLength(50)]
  18. [Required]
  19. [Display(Name = "更新者")]
  20. public string UPDATEUSER { get; set; }
  21. [Display(Name = "更新时间")]
  22. public DateTime UPDATETIME { get; set; } = DateTime.Now;
  23. //[ConcurrencyCheck]
  24. [Timestamp]
  25. [Display(Name = "版本")]
  26. public byte[] VER { get; set; }
  27. public T Copy<T>() where T : OBJ
  28. {
  29. T instance = Activator.CreateInstance<T>();
  30. foreach (PropertyInfo property in this.GetType().GetProperties())
  31. {
  32. object obj = property.GetValue((object)this);
  33. typeof(T).GetProperty(property.Name).SetValue((object)instance, obj);
  34. }
  35. return instance;
  36. }
  37. }
  38. }