/ Home / HowTo / SmartDataObject

A Smart Data Object keeps track of which properties have been changed since it was created.

The changed names can be cleared with the dataObject.ChangedNames.Clear() method.

using System;
using LJCDBClientLib;
using LJCNetCommon;

/// <summary>The Province table Data Record.</summary>
public class Province : IComparable
{
  #region Constructors

  // Initializes an object instance.
  /// 
  public Province()
  {
    ChangedNames = new ChangedNames();
  }
  #endregion

  #region Data Properties

  // Update ChangedNames.Add() statements to "Property" constant
  // if property was renamed.

  /// <summary>Gets or sets the ProvinceID value.</summary>
  //[Required]
  //[Column("ID", TypeName="int")]
  public Int32 ID
  {
    get { return mID; }
    set
    {
      mID = ChangedNames.Add("ID", mID, value);
    }
  }
  private Int32 mID;

  /// <summary>Gets or sets the Name value.</summary>
  //[Required]
  //[Column("Name", TypeName="varchar(60)")]
  public String Name
  {
    get { return mName; }
    set
    {
      value = NetString.InitString(value);
      mName = ChangedNames.Add("Name", mName, value);
    }
  }
  private String mName;

  /// <summary>Gets or sets the Description value.</summary>
  //[Column("Description", TypeName="varchar(100)")]
  public String Description
  {
    get { return mDescription; }
    set
    {
      value = NetString.InitString(value);
      mDescription = ChangedNames.Add("Description", mDescription, value);
    }
  }
  private String mDescription;

  /// <summary>Gets or sets the Abbreviation value.</summary>
  //[Column("Abbreviation", TypeName="char(3)")]
  public String Abbreviation
  {
    get { return mAbbreviation; }
    set
    {
      value = NetString.InitString(value);
      mAbbreviation = ChangedNames.Add("Abbreviation", mAbbreviation, value);
    }
  }
  private String mAbbreviation;
  #endregion

  #region Class Properties

  /// <summary>Gets a reference to the ChangedNames list.</summary>
  public ChangedNames ChangedNames { get; private set; }
  #endregion
}
/ Home / HowTo / SmartDataObject

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.