Csla 3.5: Readonly property changed

Csla 3.5: Readonly property changed

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


ajj3085 posted on Wednesday, September 24, 2008

Hi,

I have a method on a BusinessBase subclass, with a CurrentQuantity property.   This property is read / write when the object is new, readonly after it's been saved.

However, the value can change by calling a method on the instance, which will hit the database.  The new value should be shown (updated on the UI), so I use the code below.

LoadProperty<int>( CurrentQuantityProperty, cmd.NewQuantity );
OnPropertyChanged( CurrentQuantityProperty.Name );

Where cmd is the command that was executed and knows the new quantity.

I didn't call PropertyChanged because I assume that will still mark the object as dirty, which I don't want to do.

RockfordLhotka replied on Wednesday, September 24, 2008

Your solution is correct. LoadProperty() doesn't mark the object dirty or raise the PropertyChanged event. So calling OnPropertyChanged() will notify data binding of the change to refresh the UI.

ajj3085 replied on Wednesday, September 24, 2008

Great, thanks!  Just wanted to know this was the proper way to go.

Copyright (c) Marimer LLC