Does IsDirty take into account original state of properties?

Does IsDirty take into account original state of properties?

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


damo posted on Tuesday, April 17, 2007

Hi Rocky and people,

quicky on IsDirty.. Say my Business Object has a single boolean property, and through databinding (checkbox), the user changes it from true to false, IsDirty will be true. Say the user then changes the checkbox again the property is back to true again.  Does IsDirty take into account the original state? i.e. will it now return false?

Thx,

Damo

ajj3085 replied on Tuesday, April 17, 2007

No, it does not.  If you need this, you'll have to code it yourself.

damo replied on Tuesday, March 04, 2008

To answer my own question, no. Though it would be nice ...

rsbaker0 replied on Tuesday, March 04, 2008

It's not at all hard to implement if you have a code generator.

We do this in our application for other reasons (our database concurrency model tests the previous values of changed fields, so we have to have the original value of anything that is changed).

Basically all we do is maintain a dictionary of the original fields and values. If one is changing and the field isn't already in the dictionary, then we add it.

It has come in very handy of other tasks. For example, if you change a property from A to B and then back to A, the property really isn't dirty anymore even though CSLA thinks the object itself is. We have some business rules that take advantage of this (e.g. if you broke a rule by changing a property, then you can unbreak the rule by changing it back to the original value without any further testing).

damo replied on Tuesday, March 04, 2008

Did you have to make modifications to the CSLA library or was it easy to implement by inheriting BusinessBase?

Also how do you handle child lists? User removes item 1 & 2, then re-adds them. The list order may be different but it contains the same objects.

rsbaker0 replied on Wednesday, March 05, 2008

No, I haven't made any changes to CSLA. All my BO's derive from a common class between BusinessBase and the actual BO.

I can post sample property setter if it would help, but the idea is that there is "property changing" (versus "property changed") call in the setter. The property changing notification allows the base class to cache the previous value.

I haven't done anything similar with lists of BO's.

 

damo replied on Wednesday, March 05, 2008

It's ok, I can figure out that, but thx anyway.

Copyright (c) Marimer LLC