예제 #1
0
        protected virtual void OnBeforeSaveChanges()
        {
            foreach (var entry in ChangeTracker.Entries().ToList())
            {
                switch (entry.State)
                {
                case EntityState.Added:
                    _auditPropertySetter.SetCreationProperties(entry.Entity);
                    break;

                case EntityState.Modified:
                    _auditPropertySetter.SetModificationProperties(entry.Entity);
                    break;

                case EntityState.Deleted:
                    _auditPropertySetter.SetDeletionProperties(entry.Entity);
                    break;
                }
            }
        }
예제 #2
0
 /// <summary>
 /// 设置新增相关审计属性
 /// </summary>
 /// <param name="entry"></param>
 protected virtual void SetCreationAuditProperties(EntityEntry entry)
 {
     AuditPropertySetter?.SetCreationProperties(entry.Entity);
 }