Children and Parent .EditLevel/.IsDirty()

Children and Parent .EditLevel/.IsDirty()

Old forum URL: forums.lhotka.net/forums/t/484.aspx


Michael Hildner posted on Tuesday, June 27, 2006

Hi,

I have a BusinessListBase (EmployeeEditableRootList) that has a collection of BusinessBase objects (EmployeeEditableChild).

I have NOT overridden IsDirty on the parent. Yet I edit a child record, and IsDirty on the parent is true, but EditLevel is still zero.

I thought I would have to override IsDirty in the parent class, but I guess not. Also, should I be wiring up something so the parent's EditLevel gets incremented?

I guess I don't understand how things are working/should be working.

Thanks,

Mike

ajj3085 replied on Tuesday, June 27, 2006

IsDirty on a collection simply loops through all children looking for ANY dirty child object. 

You only want to call the parents BeginEdit method if you want ALL changes to the collection to be 'rolled back' on a CancelEdit.  

For example, if you call BeginEdit on the list (root) and add a  new EmployeeEditableChild, then edit a different EmployeeEC object and call CancelEdit, the new object would be removed and the change to the existing EEC would be 'forgotten.'

So, the answer to your question is, it depends on what you want to do.

HTH
Andy

Michael Hildner replied on Tuesday, June 27, 2006

Thanks Andy, that does help, especially given the example.

Mike

Copyright (c) Marimer LLC