AuditInsertOfNewEntity

Posts   
 
    
CowHills
User
Posts: 47
Joined: 14-Mar-2007
# Posted on: 02-Mar-2010 13:36:52   

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

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 02-Mar-2010 13:43:00   

I guess you have mis-read my reply in the mentioned thread.

I sugested AuditInsertOfNewEntity of an Auditor, I didn't speak about the Validator at all simple_smile

CowHills
User
Posts: 47
Joined: 14-Mar-2007
# Posted on: 02-Mar-2010 21:29:24   

I'm not familiar with the Auditor class. Could you send me a link of some online help about this subject.

Many thanks.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 02-Mar-2010 23:17:22   

It's all in the documentation

The documentation is also installed locally along with LLBLGen.

Matt