Set Property Value used for validation

Set Property Value used for validation

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


mikeclimbs posted on Wednesday, April 04, 2007

I have a Contacts Editable Root Object that has a Property DisplayName that is Properties Suffix + First Name + Last Name.

DisplayName is saved to the database and shown on lists and is also used to validate uniqueness.

I was thinking of updating the field by overriding Save, but since I need the value set for validation that doesn't work.

Any suggestions?

William replied on Wednesday, April 04, 2007

See if this helps.
 
public string DisplayName
{
  get { return _displayName; }
  protected set
  {
    _displayName = value;
    PropertyHasChanged();
  }
}
 
public string FirstName
{
  get { return _firstName; }
  set
  {
    if (value != _firstName)
    {
      _firstName = value;
      PropertyHasChanged();
 
      UpdateDisplayName();
    }
  }
}
 
private void UpdateDisplayName()
{
  this.DisplayName = _prefix + _firstName + " " + _lastName;
}
 
 
Regards,
William
 

mikeclimbs replied on Thursday, April 05, 2007

Thanks for the info.   I'll give it a try.

Mike

Copyright (c) Marimer LLC