Adding to Child Collection not marking the Root Collection as Dirty...?

Adding to Child Collection not marking the Root Collection as Dirty...?

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


jender624 posted on Monday, August 14, 2006

Hi everybody,

I have a Resource editable root collection, which is comprised of Resource child objects.  Each Resource child object in turn contains a ResourceAvailabilityCollection child collection, which is comprised of ResourceAvailability child objects.  So, in visual pseudocode, the hierarchy looks like this:

Class ResourceCollection (of Resource )

End Class

Class Resource

      Public availabilityCollection as ResourceAvailabilityCollection 

End Class

Class ResourceAvailabilityCollection (of ResourceAvailability)

End Class

Class ResourceAvailability

End Class

When I add a ResourceAvailability child object to the ResourceAvailabilityCollection child collection, my ResourceCollection is not being marked as Dirty.  Consequently, the DataPortal_Update of the ResourceCollection is not being fired, which means the Resource objects are not being updated, which means the ResourceAvailabilityCollection is not saving the new ResourceAvailability child objects to the database.

Have I set this up wrong?  How do I get my root collection to execute the update?  (I hope I haven't confused everybody...)

Thanks,

jender624

Tray replied on Tuesday, August 15, 2006

jender624,

You have not indicated if you have overridden the IsDirty and IsValid properties in the Resource business object.

For the root collection (ResourceCollection) to know that its child objects are dirty, you need to override the default implementations of IsDirty (and IsValid while you're there).

Check out page 417 of Rockfords' book (Expert VB 2005 Business Objects) for information on how to implement IsDirty for objects with collections of child objects.

In reference to the book, your Resource object is the object that requires overriding - it is the top non-collection object.

Hope this helps
Tray

jender624 replied on Tuesday, August 15, 2006

Awesome, thanks so much Tray...I completely missed the part about overriding IsDirty/IsValid.  I'll give that a shot and see if I can get this thing working.

Thanks again,

jender624

jender624 replied on Tuesday, August 15, 2006

That did it!  Thanks again!

Copyright (c) Marimer LLC