Compartir a través de


DataServiceContext.AttachTo Method (String, Object)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Notifies the DataServiceContext to start tracking the specified resource and supplies the location of the resource within the specified resource set.

Namespace:  System.Data.Services.Client
Assembly:  System.Data.Services.Client (in System.Data.Services.Client.dll)

Syntax

'Declaration
Public Sub AttachTo ( _
    entitySetName As String, _
    entity As Object _
)
public void AttachTo(
    string entitySetName,
    Object entity
)

Parameters

  • entitySetName
    Type: System.String
    The name of the set that contains the resource.

Exceptions

Exception Condition
ArgumentNullException

When entity or entitySetName are nulla null reference (Nothing in Visual Basic).

ArgumentException

When entitySetName is an empty string.

-or-

When entity does not have a key property.

InvalidOperationException

When entity is already being tracked by the context.

Remarks

If the entity is part of an object graph, this operation does not traverse the graph to add related objects. It is a shallow operation.

The method does not validate whether the specified entity set exists in the data service associated with the DataServiceContext.

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.