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