From be67c8ac203f16e7c60ec80a9e3eb3502f2206d5 Mon Sep 17 00:00:00 2001 From: Phil Schneider Date: Mon, 11 Nov 2024 10:06:15 +0100 Subject: [PATCH] fix: adjust audit entity creation (#1122) * fix audit-expression-creation to accommodate changes in updated audit-package Refs: #1121 --- .../Auditing/EntityTypeBuilderV1Extension.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/portalbackend/PortalBackend.PortalEntities/Auditing/EntityTypeBuilderV1Extension.cs b/src/portalbackend/PortalBackend.PortalEntities/Auditing/EntityTypeBuilderV1Extension.cs index 5c059a2f61..42c9bee168 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Auditing/EntityTypeBuilderV1Extension.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Auditing/EntityTypeBuilderV1Extension.cs @@ -101,9 +101,9 @@ private static MemberInitExpression CreateAuditEntityExpression(IE { var memberBindings = sourceProperties.Select(p => CreateMemberAssignment(typeof(TAuditEntity).GetMember(p.Name)[0], Expression.Property(entity, p))) - .Append(CreateMemberAssignment(typeof(TAuditEntity).GetMember(AuditPropertyV1Names.AuditV1Id.ToString())[0], Expression.New(typeof(Guid)))) + .Append(CreateMemberAssignment(typeof(TAuditEntity).GetMember(AuditPropertyV1Names.AuditV1Id.ToString())[0], Expression.Call(typeof(Guid).GetMethod(nameof(Guid.NewGuid), BindingFlags.Public | BindingFlags.Static)!))) .Append(CreateMemberAssignment(typeof(TAuditEntity).GetMember(AuditPropertyV1Names.AuditV1OperationId.ToString())[0], Expression.Constant(auditOperationId))) - .Append(CreateMemberAssignment(typeof(TAuditEntity).GetMember(AuditPropertyV1Names.AuditV1DateLastChanged.ToString())[0], Expression.New(typeof(DateTimeOffset)))); + .Append(CreateMemberAssignment(typeof(TAuditEntity).GetMember(AuditPropertyV1Names.AuditV1DateLastChanged.ToString())[0], Expression.MakeMemberAccess(null, typeof(DateTimeOffset).GetProperty(nameof(DateTimeOffset.UtcNow))!))); if (lastEditorProperty != null) {