child - grandchild relation ship

child - grandchild relation ship

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


ThomasHepp posted on Thursday, July 17, 2008

Hallo,

I think I have a simple problem. I have a BusinessListBase (=parent), which has a view BusinessBases (=childs). Each child has a BusinessListBase (=grandchild) which has BusinessBases (=great-granschilds).

All child objects (grand and great-grand too) are marked as child.

Now I simply want, that when my great-grandchild is dirty, the parent becomes dirty too. I thougt, this happens automaticly?!

A short question: How do I save my grandchild list in the best way? In the moment, I save my grandchild when I insert or update my child or I delte my granschild list when I delete my child.

 

Tim.Gray replied on Thursday, July 17, 2008

The problem is that the base IsDirty method of your root class (parent) does not automatically check any child classes. What we did was to override the IsDirty method of the parent class to check itself and any child classes for being dirty. We did the same for the IsValid method as well. C# Example:

public override bool IsDirty
{
 get
  {
   if (base.IsDirty) return true;
   if (_childs.IsDirty) return true;
   return false;
  }
}

 

JoeFallon1 replied on Thursday, July 17, 2008

The override of IsDirty and IsValid was required prior to CSLA 3.5.

I wrote my own code in a Base class so that I did not have to do it in every BO.

Rocky has now added it to the framework in 3.5 so it should "just work".

Joe

 

Copyright (c) Marimer LLC