EditableRootList update non dirty child objects

EditableRootList update non dirty child objects

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


Mark_ posted on Saturday, March 16, 2013

Hi,

I have these classes:

Child : BusinessBase

Parent : BusinessBindingListBase<Parent,Child>

In parent class i have:

protected override void DataPortal_Update()
        {
            Child_Update();
        }

Parent list fetch some data from database and fill itself. Problem is when i call Save() on parent object, it updates EVERY child object, even those which i didn't edited at all. How can i fix this, and update only deleted/edited children?!

JonnyBee replied on Saturday, March 16, 2013

Hi,

In your Child_Update check for IsDirty and if false then just return.

Mark_ replied on Saturday, March 16, 2013

Tnx Jonny. I did as you said, but, shouldn't CSLA do that check by itself? Or i did something wrong?!

JonnyBee replied on Sunday, March 17, 2013

There is situations where you need all the data to be present at the dal /remote side.

F.ex when using a messaging based system that needs ALL data - including those that were not changed by the user.

So the default action by CSLA is to call Child_Update on all children and your code can easiy decide whether or not to perform any action.

Copyright (c) Marimer LLC