Export (0) Print
Expand All

ObjectContext.ApplyPropertyChanges Method

Note: This API is now obsolete. The non-obsolete alternative is ApplyCurrentValues<TEntity>.

Applies property changes from a detached object to an object already attached to the object context.

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

[BrowsableAttribute(false)]
[ObsoleteAttribute("Use ApplyCurrentValues instead")]
public void ApplyPropertyChanges(
	string entitySetName,
	Object changed
)

Parameters

entitySetName
Type: System.String

The name of the entity set to which the object belongs.

changed
Type: System.Object

The detached object that has property updates to apply to the original object.

ExceptionCondition
ArgumentNullException

When entitySetName is null or an empty string.

-or-

When changed is null.

InvalidOperationException

When the EntitySet from entitySetName does not match the EntitySet of the object’s EntityKey.

-or-

When the entity is in a state other than Modified or Unchanged.

-or-

The original object is not attached to the context.

ArgumentException

When the type of the changed object is not the same type as the original object.

The ApplyCurrentValues<TEntity> method is used to apply property changes from a modified, detached version of an object to the original version attached to the ObjectContext. This supports scenarios, such as Web services, where an entity object is detached and sent to a remote application where property updates are made. This method enables you to more easily apply these changes back to the original object.

After ApplyCurrentValues<TEntity>, the object is in the Modified state. You must call the SaveChanges method to update the data source.

The original object must exist in the ObjectStateManager and must be in the Modified or Unchanged state. The original object is only modified if there are modified properties in the changed object.

The EntityKey property of the supplied object must be set to a valid EntityKey.

ApplyCurrentValues<TEntity> does not affect navigation properties or related objects.

ApplyCurrentValues<TEntity> only sets properties that exist in the entity metadata for the type. For example, properties that are added in a partial class are not included in the ApplyCurrentValues<TEntity> operation.

.NET Framework

Supported in: 3.5 SP1
Obsolete (compiler warning) in 4.6
Obsolete (compiler warning) in 4.5
Obsolete (compiler warning) in 4.5.1
Obsolete (compiler warning) in 4.5.2
Obsolete (compiler warning) in 4

.NET Framework Client Profile

Obsolete (compiler warning) in 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft