How can I get IsDirty false when readonly properties have been changed?

How can I get IsDirty false when readonly properties have been changed?

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


JNE posted on Wednesday, November 24, 2010

Hi All,

I'm trying to have IsDirty equal to false even if some readonly properties have been changed. The user is not actually changing these values, it's a background process that does the job

Thanks.


Jonathan.

am_fusion replied on Wednesday, November 24, 2010

Generally, If you do not want the object to be dirty then it is the responsibility of the object to do this.  What I mean is, an external process should not modify a property of the BO without the BO becoming dirty... unless that is the intent of the property (in which case the property setter should use LoadProperty instead of SetProperty).

 

That being said, there are two mechanisms for changing properties without IsDirty being set to true: BypassPropertyChecks and LoadProperty 

public class SomeEntity : BusinessBase<SomeEntity>
{

    public void SomeMethodToBeCalledByAnotherEntity()
    {
           //using BypassPropertyCheck
           using(BypassPropertyChecks)
           {
                 this.SomeProperty = "some value";
           }
           //using LoadProperty
           LoadProperty(SomePropertyProperty, "some value");
    }

}

 

JNE replied on Thursday, November 25, 2010

That's what I did first. Using LoadProperty works pretty well BUT my UI is not being refreshed if I use this.

I have set the update mode of my controls to OnPropertyChanged. Is there a way to force my UI to rebind those properties even if the PropertyChanged event has not been raised?

Thanks for your reply. Big Smile

Jonathan.

JonnyBee replied on Thursday, November 25, 2010

Hi,

Call method OnPropertyChanged(propertyName) i your property setter to notify UI that the property has changed.

OnPropertyChanged will not mark the object as dirty and trigger validation rules as PropertyhasChanged does.

JNE replied on Thursday, November 25, 2010

Many Thanks JonnyBee!

You rock! Yes


Jonathan.

Copyright (c) Marimer LLC