Open PizzaConsole opened 3 years ago
Not sure what you mean by overriding
- can you explain a bit more what the problem you're seeing? Did you turn-off ChangeTracking
by any chance?
@274188A See above
So the job of the AuditableContext is to keep a history of changes made. It only takes care of entities that have implemented the IAuditable
You can check for yourself by inspecting the Tables ChatHistory
and AuditTrails
So the idea basically is that the Save
call for any entity that implements the IAuditable interface will have it call intercepted
if you like to do some entries into the AuditTrails table. for example if you were able to edit a chat item then those edit changes would be recorded in the AuditTrails table. The ChatHistory is the chat itself - not the 'edited changes'. I can see how it would be easy to get this mixed up due to the naming...
Ah, I see that OnAfterSaveChanges
calls SaveChangesAsync
which calls it from BlazorHeroContext
, yeah that is a bit confusing.
I know I just closed this, but I just walked through the code in a debugging session and I understand what is happening now. It is inefficient. If you follow the save when it is called in the chat service you can see that it calls AuditableContext.SaveChangesAsync
first then it calls BlazorHeroContext.SaveChangesAsync
in AuditableContext.OnAfterSaveChanges
which then calls AuditableContext.SaveChangesAsync
again... this can definitely be optimized.
might be best to raise a fresh ticket with a good Title to help out the author
Or you could just suggest a "good" title to rename this ticket
wow - good luck champ
Haha that was my reaction. I will just let the author review this when they get time.
BlazorHeroContext.SaveChangesAsync does not actually override AuditableDbContext.SaveChangesAsync.
AuditableContext
BlazorHeroContext
This does NOT override the
AuditableContext
it overrides theDbContext
is it missingstring userId = null,
Example in
ChatService
: When it saves the changes here it is calling the AuditConext NOT the HeroContext