Ok so here is a simplified version of the code
public override bool SaveEntity(IEntity2 entityToSave, bool refetchAfterSave, IPredicateExpression updateRestriction, bool recurse)
{
// Some code here for audit
// Delete the entity if some conditions are filled
bool deleteEntity = true; // in fact there is some code to determine true or false
if (deleteEntity)
{
// don't save, but delete it !
return this.DeleteEntity(entityToSave);
}
// Save the entity
return base.SaveEntity (entityToSave, refetchAfterSave, updateRestriction, recurse);
}
In version 2004.1, it work fine because for each entity in the graph it go in my SaveEntity method (override of base method, and the base method call itself recursively).
But now, I suppose the base method doesn't call itself recursively ... so I can't change the way the entity is saved, and I can't delete it when needed.
Example :
I've an Employee 'myEmployee' which is modified and need to be saved.
I've in myEmployee.TimeLineElement several entities which also have to be saved. But in these collection, when saving a element I need (if it meet some conditions) to delete it instead of update it.
Previously I checked these conditions in the SaveEntity. The method was called for each entity by llblgen:
SaveEntity(myEmployee, recursive=true) (called by my code)
recursively called by llblgen --> SaveEntity(myTimeline1)
recursively called by llblgen --> SaveEntity(myTimeline2)
recursively called by llblgen --> SaveEntity(myTimeline3) --> some conditions are filled --> DeleteEntity(myTimeline3)
I hope it's more clear now. Thank for your help.