ObjectContext.ApplyPropertyChanges(String, Object) 方法

定義

警告

Use ApplyCurrentValues instead

將已中斷連結物件中的屬性變更套用至已經附加至物件內容的物件。

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)

參數

entitySetName
String

此物件所屬之實體集的名稱。

changed
Object

具有要套用至原始物件之屬性更新的已中斷連結物件。

屬性

例外狀況

entitySetNamenull 或空字串時。

-或-

changednull 時。

entitySetNameEntitySet 不符合物件之 EntityKeyEntitySet 時。

-或-

當實體處於 ModifiedUnchanged 以外的狀態時。

-或-

原始物件沒有附加至內容。

changed 物件的型別與原始物件的型別不同時。

備註

ApplyCurrentValues 方法是用來將已修改且已中斷連結版本之物件中的屬性變更套用至附加至 ObjectContext 的原始版本。 這會支援 Web 服務等案例,其中實體物件已中斷連結並且傳送至進行屬性更新的遠端應用程式。 這個方法可讓您更輕鬆地將這些變更套用回原始物件。

ApplyCurrentValues 之後,此物件會處於 Modified 狀態中。 您必須呼叫 SaveChanges 方法來更新資料來源。

原始物件必須存在 ObjectStateManager 中,而且必須處於 ModifiedUnchanged 狀態中。 只有在物件中有 changed 修改的屬性時,才會修改原始物件。

提供之物件的 EntityKey 屬性必須設定為有效的 EntityKey

ApplyCurrentValues 不會影響導覽屬性或相關物件。

ApplyCurrentValues 只會針對此型別設定存在實體中繼資料中的屬性。 例如,加入部分類別中的屬性就不會包含在 ApplyCurrentValues 作業中。

適用於