isDirty not set when Child is updated

isDirty not set when Child is updated

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


gartnerj posted on Thursday, July 19, 2007

Folks,

I have a Editable Root class that has a Child List as part of the class.

When I am testing a SAVE for the Editable Root, I am doing an Add to the child list:

EditableRoot.ChildList.Add(item);

Then I do the EditableRoot.ApplyEdit(); and EditableRoot.Save();

It looks like the Update to the ChildList isn't causing the isDirty to be set, so the Save does nothing (doesn't call Dataportal.Insert or Dataportal.Update on the EditableRoot).

I am using CSLA 2.1 -- any ideas?  I'm sure it's probably something basic I'm not doing in the child list.

JoeFallon1 replied on Thursday, July 19, 2007

Actually it is something basic you are not doing in the Root BO.

You should always override IsValid and IsDirty to account for the presence of the Child Collection or Child BO.

Page 417 of the VB book has a sample:

IsValid:
  Return MyBase.IsValid AndAlso mResources.IsValid

IsDirty:
  Return MyBase.IsDirty OrElse mResources.IsDirty

Joe

 

gartnerj replied on Thursday, July 19, 2007

Thansk Joe -- I'll give that a try!

gartnerj replied on Thursday, July 19, 2007

Thanks Joe -- that was the problem!  MUCH appreciated!

Copyright (c) Marimer LLC