Bewerken

Share via


ObjectContext.ApplyPropertyChanges(String, Object) Method

Definition

Caution

Use ApplyCurrentValues instead

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

public:
 void ApplyPropertyChanges(System::String ^ entitySetName, System::Object ^ changed);
public void ApplyPropertyChanges (string entitySetName, object changed);
[System.ComponentModel.Browsable(false)]
[System.Obsolete("Use ApplyCurrentValues instead")]
public void ApplyPropertyChanges (string entitySetName, object changed);
member this.ApplyPropertyChanges : string * obj -> unit
[<System.ComponentModel.Browsable(false)>]
[<System.Obsolete("Use ApplyCurrentValues instead")>]
member this.ApplyPropertyChanges : string * obj -> unit
Public Sub ApplyPropertyChanges (entitySetName As String, changed As Object)

Parameters

entitySetName
String

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

changed
Object

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

Attributes

Exceptions

When entitySetName is null or an empty string.

-or-

When changed is null.

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.

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

Remarks

The ApplyCurrentValues 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, 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 does not affect navigation properties or related objects.

ApplyCurrentValues 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 operation.

Applies to