I have this table mapping (details don't really matter I think):
WithTable("COPACKER_FACILITY");
Id(x => x.FacilityNumber, "FACILITY_NUM").GeneratedBy.Sequence("FACSEQ");
Map(x => x.FacilityName, "FACILITY_NAME").Not.Nullable().Trimmed();
Map(x => x.AddressLine1, "ADDR1").Not.Nullable().Trimmed();
...
WithTable("FACIL_OTH_AUDIT_INFO", m =>
{
m.WithKeyColumn("FACILITY_NUM");
m.Map(x => x.ProdnShiftsNum, "PRODN_SHIFTS_NUM").Not.Nullable();
m.Map(x => x.ProdnCapacity, "PRODN_CAPACITY").Not.Nullable();
m.Map(x => x.ProdnLinesNum, "PRODN_LINES_NUM").Not.Nullable();
m.Map(x => x.AuditScore, "AUDIT_SCORE");
m.References(x => x.FacilStatus, "STATUS_IND").Not.Nullable();
});
HasMany(x => x.ComplianceFlags)
.KeyColumnNames.Add("FACILITY_NUM")
.Inverse()
.Cascade.All();
...
The reason for the one to one table is for audit reasons. There's a FACIL_OTH_AUDIT_INFO_HIST
table that should get a record for every insert and update in the main table.
My question: How can I know when an insert or update happens in that table so I know to insert an audit record?
Many thanks!