ChangeEntry.cs 1020 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using Microsoft.EntityFrameworkCore;
  2. using System.Reflection;
  3. namespace Masuit.Tools.Core;
  4. public class ChangeEntry<T>
  5. {
  6. /// <summary>
  7. /// 所属实体
  8. /// </summary>
  9. public T Entity { get; set; }
  10. /// <summary>
  11. /// 实体类型
  12. /// </summary>
  13. public Type EntityType { get; set; }
  14. /// <summary>
  15. /// 变更类型
  16. /// </summary>
  17. public EntityState EntityState { get; set; }
  18. /// <summary>
  19. /// 字段变更信息
  20. /// </summary>
  21. public List<ChangePropertyInfo> ChangeProperties { get; set; }
  22. public string ChangeDescription => ChangeProperties.Select(p => p.ChangeDescription).Join("; ");
  23. /// <summary>Returns a string that represents the current object.</summary>
  24. /// <returns>A string that represents the current object.</returns>
  25. public override string ToString()
  26. {
  27. return $"{ChangeDescription},实体:{EntityType.FullName},变更类型:{EntityState}";
  28. }
  29. }
  30. public class ChangeEntry : ChangeEntry<object>
  31. {
  32. }