I am using LLBLGen v3.1 with an adapter project targeting the 4.0 framework and a SQL Server Express database.
I have a PassEntity and under certain circumstances I want to create a PassHistoryEntity when the PassEntity is saved. So I coded this:
PassEntity pass = new PassEntity();
<set some fields>
adapter.SaveEntity(pass, true, true); // refetch, recurse
and in the PassEntity I have coded this:
protected override void OnBeforeEntitySave()
{
// insert a history record?
PassHistoryEventType eventType = GetEventType();
if (eventType != PassHistoryEventType.NoEvent)
{
PassHistoryEntity history = new PassHistoryEntity();
history.TransitAccountId = this.TransitAccountId;
history.TaXFpId = this.TaXFpId;
history.ApiLogId = this.ApiLogId;
history.EventType = (int)eventType;
history.ExpirationDtm = (DateTime)this.ExpirationDtm;
history.StartDtm = this.StartDtm;
history.EndDtm = this.EndDtm;
this.PassHistories.Add(history);
}
base.OnBeforeEntitySave();
}
I have set breakpoints in the OnBeforeEntitySave method, and I know that it is creating the PassHistory entity and adding it to the PassHistories collection in the PassEntity. I even checked that the PassHistoryEntity IsNew and IsDirty. But the PassHistoryEntity is not persisted to the database even though I have coded a recursive save of the PassEntity. Is there another method I should be overriding instead?