DataServiceContext.AttachTo 方法

定義

通知 DataServiceContext 開始追蹤指定的資源並提供資源在指定之資源集內的位置。

多載

AttachTo(String, Object)

通知 DataServiceContext,開始追蹤指定的資源,並提供指定的資源集內資源的位置。

AttachTo(String, Object, String)

通知 DataServiceContext 開始追蹤指定的資源並提供資源在指定之資源集內的位置。

AttachTo(String, Object)

通知 DataServiceContext,開始追蹤指定的資源,並提供指定的資源集內資源的位置。

public:
 void AttachTo(System::String ^ entitySetName, System::Object ^ entity);
public void AttachTo (string entitySetName, object entity);
member this.AttachTo : string * obj -> unit
Public Sub AttachTo (entitySetName As String, entity As Object)

參數

entitySetName
String

包含資源的實體集名稱。

entity
Object

DataServiceContext 要追蹤的資源。 資源是以未變更狀態附加。

例外狀況

entityentitySetNamenull

entitySetName 為空字串。

-或-

entity 沒有已定義的索引鍵屬性。

entity 內容已經追蹤。

備註

如果實體是物件圖形的一部分,這項作業不會周遊該圖形以加入相關物件。 這是一種淺層作業。

此方法不會驗證與 DataServiceContext 相關聯的資料服務中是否發生指定的實體集。

適用於

AttachTo(String, Object, String)

通知 DataServiceContext 開始追蹤指定的資源並提供資源在指定之資源集內的位置。

public:
 void AttachTo(System::String ^ entitySetName, System::Object ^ entity, System::String ^ etag);
public void AttachTo (string entitySetName, object entity, string etag);
member this.AttachTo : string * obj * string -> unit
Public Sub AttachTo (entitySetName As String, entity As Object, etag As String)

參數

entitySetName
String

字串值,包含實體附加至的實體集名稱。

entity
Object

要加入的實體。

etag
String

etag 值,表示上次從資料服務擷取時的實體狀態。 此值被視為不透明的字串;用戶端程式庫不會對它執行任何驗證。

例外狀況

entitySetNamenull

-或-

entitynull

entitySetName 為空字串。

-或-

提供的物件沒有索引鍵屬性。

提供的物件已經由內容追蹤。

備註

呼叫這個方法會通知 DataServiceContext,開始追蹤指定的實體並識別該實體所屬的實體集。

如果實體是物件圖形的一部分,這項作業不會周遊該圖形以加入相關物件。 物件是以未變更狀態加入 DataServiceContext。 此方法不會驗證與 DataServiceContext 相關聯的資料服務中是否發生指定的實體集。

如果使用有 etag 的多載,則會使指定的 etag 與新附加的實體產生關聯。 於是,etag 就會根據 HTTP 語意隨著實體的所有後續更新或查詢作業傳送至資料服務。 不建議手動產生 etag 值,提供此多載是為了讓可能已序列化並儲存的實體連同相關並行中繼資料重新附加。

適用於