BaseEntity.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Microsoft.EntityFrameworkCore;
  2. using System.ComponentModel.DataAnnotations;
  3. using System.Xml.Linq;
  4. namespace DW5S.Entity
  5. {
  6. [Index(nameof(UpdateTime))]
  7. public abstract class BaseEntity
  8. {
  9. public BaseEntity()
  10. {
  11. this.CreateTime = DateTime.Now;
  12. this.UpdateTime = DateTime.Now;
  13. }
  14. [Key]
  15. [Display(Name = "编号")]
  16. public int Id { get; set; }
  17. [Display(Name = "创建时间")]
  18. [DisplayFormat(DataFormatString = "yyyy-MM-dd HH:mm:ss")]
  19. public DateTime CreateTime { get; set; }
  20. [Display(Name = "更新时间")]
  21. [DisplayFormat(DataFormatString = "yyyy-MM-dd HH:mm:ss")]
  22. public DateTime UpdateTime { get; set; }
  23. }
  24. public abstract class BaseEntityLong : BaseEntity
  25. {
  26. public BaseEntityLong()
  27. {
  28. this.CreateTime = DateTime.Now;
  29. this.UpdateTime = DateTime.Now;
  30. }
  31. [Key]
  32. [Display(Name = "编号")]
  33. public new long Id { get; set; }
  34. }
  35. }