Binding and exceptions throw by the SetProperty erroneously.

Binding and exceptions throw by the SetProperty erroneously.

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


Lazaro posted on Friday, July 09, 2010

Hello,

We are migrating CSLA from 1.3.0 to 3.8.2.

 

Our property SET had this format:

public long FICSLoanID
{
   get { return _fICSLoanID; }
   set
   {
     if(_fICSLoanID != value)
     {
       AssertCanEditFICSLoanID();
       _fICSLoanID = value;
       ValidateFICSLoanNumberRules();
       MarkDirty();
      }
    }
}

 

With the conversion:

private static PropertyInfo<long> FICSLoanIDProperty = RegisterProperty<long>(c => c.FICSLoanID);
public long FICSLoanID
{


  get { return GetProperty(FICSLoanIDProperty, _fICSLoanID); }
  set { SetProperty(FICSLoanIDProperty, ref _fICSLoanID, value); }
}


 


The AssertCanEditFICSLoanID  and ValidateFICSLoanNumberRules logic were moved to the

Business Rules and  Authorization Rules logic in the new version.


In the UI we are using a BindingSource windows control.


 


The problem that we are having is that when we edit a UI control that is bound (through the BindingSource) to a Property of a business object, other properties, whose UI controls were not touched, also get their Set called (with their same values).  Some of those properties are ReadOnly (they should not be called), so they throw exceptions and the binding gets unstable. This happens even when we make the controls bound to those properties ReadOnly or Disable.


 


We did not get this before since we made sure that the Values were changing “if(_fICSLoanID != value)” before we validate any rules; knowing that the binding did set properties not being set in the UI with the same values. However, with the new logic the checking for Business Rules and Authorization Rules happens even if the values being set are the same.


 


We would like some help to correct the problem, since it seems that other people must have had this issue before.



Thanks,


Lazaro


 

RockfordLhotka replied on Saturday, July 10, 2010

The SetProperty() method does check to see if the new value equals the existing value, and it does no work if they are the same.

Copyright (c) Marimer LLC