Fetch Audit Data for Navigation Properties #383
Unanswered
manideep418
asked this question in
Q&A
Replies: 1 comment 6 replies
-
Not sure if I understand, but you can obtain the EF audit event with using Audit.EntityFramework;
...
var efEvent = auditEvent.GetEntityFrameworkEvent();
string table = efEvent.Entries[0].Table;
obejct original_entity = efEvent.Entries[0].GetEntry().Entity;
//... Or if you want to access the audited entity object on the action: .AuditEntityAction((ev, entry, auditEntity) =>
{
var entity = entry.GetEntry().Entity;
} |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I have the junction table with many-to-many relation like below
Student -> StudentCourse <- Course
And my AuditCore config is like below
Audit.Core.Configuration.Setup()
.UseEntityFramework(_ => _
.AuditTypeMapper(t => typeof(AuditLog))
.AuditEntityAction((ev, entry, entity) =>
{
entity.AuditData = entry.ToJson();
entity.EntityType = entry.EntityType.Name;
entity.AuditDate = DateTimeOffset.Now;
entity.AuditUser = ev.CustomFields["ContextUser"].ToString();
})
.IgnoreMatchedProperties(true));
Now I would like to get the AuditData from Audit Event even from the NavigationProperty i.e., StudentCourse. Could you please help me with any suggestions.
Beta Was this translation helpful? Give feedback.
All reactions