Folks,
I'm having a bit of trouble understanding how to have a BO with a collection of Child objects to be marked IsDirty=false on create when I have added items to the child collection.
I have done the override of:
public
override bool IsDirty{
get { return base.IsDirty || _contactsList.IsDirty; }}
but when I do the MarkOld() before returning from the BO, it looks to the UI like the BO is marked Dirty (and since on create I have done an Add to the list, I'm guessing it would be. )
How do I set the _contactList.IsDirty to false in this case (since IsDirty on the list is only a get parm)??
Thanks,
Jim
The child object you add to the list must also be not dirty. Collections are dirty or not dirty based entirely on the state of their children (and the deletedList, which doesn't matter here).
So make that new child be not dirty and you should be set.
Thanks Rocky -- the save actually builds XML from all of the objects in the BO to save to the db, so the "children" don't save themselves for this object -- only the parent.
I did check the children of list, and that object has a MarkOld() on create/fetch (i was pretty sure from the book that was what I needed to do), so I'm not sure why this is still flagging the parent as IsDirty -- I'll have to do some more investigation.
Did you solve this? I'm having the same problem, currently can't get my parent BO to update when I call save and it has a new child object.
I have a parent BO which has a list of children which is populated through the parent correctly. Do I call parent->list->AddNew() and work with the object? I'm sure I've got this to work before. I'm working in VB.
Or should it be created through the UI:
Dim temp_childitem as childitem = New ChildItem
Dim existing_parentitem.listofchildren.add(temp_childitem)
editform_open_withchild(childitem)
Answer to this of course was to override AddNewCore()
Copyright (c) Marimer LLC