Question about saving editable root list

Question about saving editable root list

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


wjcomeaux posted on Friday, December 10, 2010

I'm trying to fix a bug in the CodeSmith templates and in research I came across this thread.

http://forums.lhotka.net/forums/p/6265/30565.aspx#30565

Basically it shows that the ERL should just call Child_Update().
I see in our generation template that we are doing that, but only if the list itself is a child object, otherwise the template generates this code:

for (int index = 0; index < DeletedList.Count; index++)
{
   DeletedList[index] = DeletedList[index].Save();
}
           
DeletedList.Clear();

for (int index = 0; index < Items.Count; index++)
{
    Items[index] = Items[index].Save();
}

Is there ever a case when this code would be valid or should the DataPortal_Update
for an ERL always just look like this:
//Configure myConnection
bool cancel = false;
OnUpdating(ref cancel);
if (cancel) return;

RaiseListChangedEvents = false;

Child_Update(myConnection);

RaiseListChangedEvents = true;

OnUpdated();

Thanks for any input,
Will

RockfordLhotka replied on Friday, December 10, 2010

Unless you have some weird dependency issues with child objects, you should always just be able to call Child_Update to do the work. It just contains the code you listed at the top of your post after all :)

wjcomeaux replied on Friday, December 10, 2010

That is what I thought and what I was hoping. Nothing weird happening here, just addressing a bug in the templates and ot wanting to add a new one accidentally by removing potentially useful functionality.

 

Thanks,
Will

bniemyjski replied on Saturday, December 18, 2010

Hello,

Thanks for reporting this Will, I'll get this fixed. I've logged this as a bug here (http://code.google.com/p/codesmith/issues/detail?id=537). Please add any comments that you have to this bug ID.

Thanks

-Blake Niemyjski

Copyright (c) Marimer LLC