This documentation is archived and is not being maintained.

EntityObject.ReportPropertyChanging Method

Notifies the change tracker that a property change is pending.

Namespace:  System.Data.Objects.DataClasses
Assembly:  System.Data.Entity (in System.Data.Entity.dll)

protected override sealed void ReportPropertyChanging(
	string property
)

Parameters

property
Type: System.String

The name of the changing property.

ExceptionCondition
ArgumentNullException

property is null.

When an entity type is generated by the Entity Data Model tools, the ReportPropertyChanging method is called before a property change to cache the current value of the property in the IEntityChangeTracker so that this value can be used as the original value for the property.

This method calls the EntityMemberChanging method in the change tracker.

When tracking changes that are made to the property of a custom object, you must call the ReportPropertyChanging method. Do this when the object inherits from EntityObject. For more information, see Reporting Changes in Custom Data Classes (Entity Framework).

The following example shows how to track changes when setting the Status property on the Order object:

[EdmScalarPropertyAttribute(IsNullable = false)]
public byte Status
{
    get 
    {
        return _status;
    }
    set
    {
        if (_status != value)
        {
            ReportPropertyChanging("Status");
            _status = value;
            ReportPropertyChanged("Status");
        }
    }
}

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5 SP1
Show: