共用方式為


DataServiceContext.AttachTo 方法 (String, Object)

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

命名空間:  System.Data.Services.Client
組件:  Microsoft.Data.Services.Client (在 Microsoft.Data.Services.Client.dll 中)

語法

'宣告
Public Sub AttachTo ( _
    entitySetName As String, _
    entity As Object _
)
'用途
Dim instance As DataServiceContext
Dim entitySetName As String
Dim entity As Object

instance.AttachTo(entitySetName, entity)
public void AttachTo(
    string entitySetName,
    Object entity
)
public:
void AttachTo(
    String^ entitySetName, 
    Object^ entity
)
member AttachTo : 
        entitySetName:string * 
        entity:Object -> unit 
public function AttachTo(
    entitySetName : String, 
    entity : Object
)

參數

  • entitySetName
    型別:System.String
    包含資源的實體集名稱。

例外狀況

例外狀況 條件
ArgumentNullException

當 entity 或 entitySetName 為 nullnull 參考 (在 Visual Basic 中為 Nothing) 時。

ArgumentException

當 entitySetName 是空字串時。

-或-

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

InvalidOperationException

當 entity 已經受到內容追蹤時。

備註

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

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

請參閱

參考

DataServiceContext 類別

AttachTo 多載

System.Data.Services.Client 命名空間