AuditedEntity.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.ComponentModel.DataAnnotations.Schema;
  3. namespace Abp.Domain.Entities.Auditing
  4. {
  5. /// <summary>
  6. /// A shortcut of <see cref="AuditedEntity{TPrimaryKey}"/> for most used primary key type (<see cref="int"/>).
  7. /// </summary>
  8. [Serializable]
  9. public abstract class AuditedEntity : AuditedEntity<int>, IEntity
  10. {
  11. }
  12. /// <summary>
  13. /// This class can be used to simplify implementing <see cref="IAudited"/>.
  14. /// </summary>
  15. /// <typeparam name="TPrimaryKey">Type of the primary key of the entity</typeparam>
  16. [Serializable]
  17. public abstract class AuditedEntity<TPrimaryKey> : CreationAuditedEntity<TPrimaryKey>, IAudited
  18. {
  19. /// <summary>
  20. /// Last modification date of this entity.
  21. /// </summary>
  22. public virtual DateTime? LastModificationTime { get; set; }
  23. /// <summary>
  24. /// Last modifier user of this entity.
  25. /// </summary>
  26. public virtual long? LastModifierUserId { get; set; }
  27. }
  28. /// <summary>
  29. /// This class can be used to simplify implementing <see cref="IAudited{TUser}"/>.
  30. /// </summary>
  31. /// <typeparam name="TPrimaryKey">Type of the primary key of the entity</typeparam>
  32. /// <typeparam name="TUser">Type of the user</typeparam>
  33. [Serializable]
  34. public abstract class AuditedEntity<TPrimaryKey, TUser> : AuditedEntity<TPrimaryKey>, IAudited<TUser>
  35. where TUser : IEntity<long>
  36. {
  37. /// <summary>
  38. /// Reference to the creator user of this entity.
  39. /// </summary>
  40. [ForeignKey("CreatorUserId")]
  41. public virtual TUser CreatorUser { get; set; }
  42. /// <summary>
  43. /// Reference to the last modifier user of this entity.
  44. /// </summary>
  45. [ForeignKey("LastModifierUserId")]
  46. public virtual TUser LastModifierUser { get; set; }
  47. }
  48. }