Started to use CSLA here

Started to use CSLA here

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


Jags posted on Friday, April 27, 2007

Hi everybody,

We have also started using the CSLA framework in our object.

I would like to clarify one doubt.

Could anybody please tell me when we have to use MarkDirty(). I have seen in lot of URLs like it has implemented immediately after invoking BrokenRules.CheckRules(). Why are we doing this.

ajj3085 replied on Friday, April 27, 2007

You rarely need to call it yourself.  Your property setters usually call it indirectly, because the PropertyHasChanged method will call MarkDirty (and run rules for the property).

Outside that, you would call it if your object has changed state and could be saved to the database (if its also valid) outside the normal property setters.

HTH
Andy

Jags replied on Monday, April 30, 2007

Thanks a lot for giving me a wonderfull response Andy.
 
Andy: You rarely need to call it yourself.  Your property setters usually call it indirectly, because the PropertyHasChanged method will call MarkDirty (and run rules for the property).
Jags: Do we need to call PropertyHasChanged() method in the property setters?

Andy: Outside that, you would call it if your object has changed state and could be saved to the database (if its also valid) outside the normal property setters.
 
Jags: So MarkDirty() means, if the object has the change in its properties or values we need to set the object as dirty. It is not the case like if the object is invalid(failing a validation rule) we need to mark it as dirty.

HTH
Andy

ajj3085 replied on Monday, April 30, 2007

Jags:
Do we need to call PropertyHasChanged() method in the property setters?


Yes.

Jags:
So MarkDirty() means, if the object has the change in its properties or values we need to set the object as dirty. It is not the case like if the object is invalid(failing a validation rule) we need to mark it as dirty.


IsValid is based on the BrokenRulesConnection.  Rules are run in response to property changes (one of the things PropertyHasChanged does). 

Dirty means the object has been modified since it was loaded from the database.  Check out the books if you want to know more details.

Copyright (c) Marimer LLC