You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When SaveChanges fails (eg. no permission to save Detail-Table), then the Detail-Entity is reloaded (Changes reverted), AuditLogs will be inserted at the next SaveChanges.
Is there a useful workaround for that usecase? I could try to remove all pending AuditLogs associated with that Detail-Entity, but I feel like that would be the job of the TrackerContext :)
varmaster=dbcontext.Masters.FirstOrDefault();vardetail=master.Detail.FirstOrDefault();detail.TextColumn="This ist a Test change, that should not show up!";try{dbcontext.SaveChanges();}catch(DbUpdateExceptionex){SqlExceptioninnerException=ex.InnerException?.InnerExceptionasSqlException;if(innerException!=null&&(innerException.Number==229||innerException.Number==230)){// Show MessageBox: No Permission// User closes Edit-Dialog, does not save Detail-Entity, Detail-Entity gets refreshed// (I know, this is not the right place to put that code, but it illustrates what the user could do)dbcontext.Entry(detail).Reload();// User SavesChangesdbcontext.SaveChanges();}elsethrowex;}
AuditLogId
UserName
EventDateUTC
EventType
TypeFullName
RecordId
PropertyName
OriginalValue
NewValue
1
NULL
2023-02-06 12:33:30.723
0
Test_redundant.Master
1
MasterId
NULL
1
2
NULL
2023-02-06 12:33:30.733
0
Test_redundant.Detail
1
DetailId
NULL
1
2
NULL
2023-02-06 12:33:30.733
0
Test_redundant.Detail
1
Master_MasterId
NULL
1
3
NULL
2023-02-06 12:44:20.713
2
Test_redundant.Detail
1
TextColumn
NULL
This ist a Test change, that should not show up!
The text was updated successfully, but these errors were encountered:
When SaveChanges fails (eg. no permission to save Detail-Table), then the Detail-Entity is reloaded (Changes reverted), AuditLogs will be inserted at the next SaveChanges.
Is there a useful workaround for that usecase? I could try to remove all pending AuditLogs associated with that Detail-Entity, but I feel like that would be the job of the TrackerContext :)
The text was updated successfully, but these errors were encountered: