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; } } }
/// <summary> /// 设置新增相关审计属性 /// </summary> /// <param name="entry"></param> protected virtual void SetCreationAuditProperties(EntityEntry entry) { AuditPropertySetter?.SetCreationProperties(entry.Entity); }