I hope that I am not overlooking something but CSLA.net calls the CancelEdit() even if the object is new or never committed and editlevel <= editleveladded.
The call is in BusinessBase here:
void System.ComponentModel.IEditableObject.CancelEdit()
Why not call CancelEdit() after the check for IsNew etc..: since new objects. Is there a need to attempt to undo something that basically has a chance to be removed from the collection?
Based on this, is there a scenario (reason) as to why the CancelEdit is always called? I know reflection for no reason slows down the application unecessarily?
Suggest putting CancelEdit() in a else clause when the if clause is false:
void System.ComponentModel.IEditableObject.CancelEdit(){
if (_bindingEdit){
if (IsNew && _neverCommitted && EditLevel <= EditLevelAdded){
// we're new and no EndEdit or ApplyEdit has ever been // called on us, and now we've been cancelled back to // where we were added so we should have ourselves // removed from the parent collectionif (Parent != null)
Parent.RemoveChild(this);
}
else
{
CancelEdit();
}
}
Copyright (c) Marimer LLC