Update Children (Template)Update Children (Template)
Old forum URL: forums.lhotka.net/forums/t/2415.aspx
Robert posted on Friday, February 23, 2007
Hi, I notice that in the template "EditableChildList", the Update() method does not check whether old items are dirty. Is there a reason for this that I'm missing out on, or is it ok to implement a check?
internal
void Update(object parent)
{
RaiseListChangedEvents = false;
foreach (EditableChild item in DeletedList)
item.DeleteSelf();
DeletedList.Clear();
foreach (EditableChild item in this)
{
if (item.IsNew)
item.Insert(parent);
else
item.Update(parent); //Why not check here if the item is dirty?
}
RaiseListChangedEvents = true;
}
brgds
Robert
ajj3085 replied on Friday, February 23, 2007
Probably because the template is just a starting point.
There are two ways to view this; one is that the item should be smart enough to know whether or not to actually do the update. The other is that the list should be smart enough to call or not call Update.
I'm not sure there's a right answer in this case, but the template probably doesn't want to assume that you want the collection to do the check; if you want it, its easily added, but if you don't then you need not do anything.
andy
JoeFallon1 replied on Friday, February 23, 2007
The first line of code for each of my Child Update methods is:
If Not Me.IsDirty Then
Exit Sub
End If
So the collection doesn't do the check, the child in the collection does its own.
Joe
Robert replied on Saturday, February 24, 2007
Thanks gays...
brgds
Robert
Copyright (c) Marimer LLC