Hi,
My journey in solving my problem started in this thread: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=8412&StartAtMessage=0
The scenario is as follow: I've got a Master and Child record. I want to add a child record when I'm saving a master record.
I've tried to achieve this by implementing the OnBeforeEntitySave method without success. The master record is saved but the child record isn't.
After reading the thread as mentioned above, I've implemted the CreateValidator method.
protected override IValidator CreateValidator()
{
IValidator validator = new TrackAndTraceValidator();
return validator;
}
public class TrackAndTraceValidator : IValidator
{
#region IValidator Members
public void AssignedToEntity(IEntityCore involvedEntity) { }
public void UnassignedFromEntity(IEntityCore involvedEntity) { }
public void ValidateEntity(IEntityCore involvedEntity) { }
public void ValidateEntityAfterLoad(IEntityCore involvedEntity) { }
public void ValidateEntityAfterSave(IEntityCore involvedEntity) { }
public void ValidateEntityBeforeDelete(IEntityCore involvedEntity) { }
public void ValidateEntityBeforeSave(IEntityCore involvedEntity)
{ ((TrackAndTraceEntity)involvedEntity).AddHistoryEntry(-1); }
public bool ValidateFieldValue(IEntityCore involvedEntity, int fieldIndex, object value)
{
return true;
}
#endregion
}
Still, this hasn't solved my problem either.
My main question remains: Is it possible to add related entities within the save action of the parent record and successfully save both records.
Cheers,
Andre