Skip to content

Commit f4b5d95

Browse files
authored
Use the Created DateTimeOffset for initial LastModified in MainAuditableEntityInterceptor.UpdateEntities
1 parent d11a7fb commit f4b5d95

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Infrastructure/Data/Interceptors/AuditableEntityInterceptor.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ public void UpdateEntities(DbContext? context)
3939

4040
foreach (var entry in context.ChangeTracker.Entries<BaseAuditableEntity>())
4141
{
42-
if (entry.State == EntityState.Added)
43-
{
44-
entry.Entity.CreatedBy = _user.Id;
45-
entry.Entity.Created = _dateTime.GetUtcNow();
46-
}
47-
4842
if (entry.State == EntityState.Added || entry.State == EntityState.Modified || entry.HasChangedOwnedEntities())
4943
{
44+
var utcNow = _dateTime.GetUtcNow();
45+
if (entry.State == EntityState.Added)
46+
{
47+
entry.Entity.CreatedBy = _user.Id;
48+
entry.Entity.Created = utcNow;
49+
}
5050
entry.Entity.LastModifiedBy = _user.Id;
51-
entry.Entity.LastModified = _dateTime.GetUtcNow();
51+
entry.Entity.LastModified = utcNow;
5252
}
5353
}
5454
}

0 commit comments

Comments
 (0)