Export (0) Print
Expand All

DataServiceContext.AttachTo Method (String, Object)

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)

public void AttachTo(
	string entitySetName,
	Object entity
)

Parameters

entitySetName
Type: System.String
The name of the set that contains the resource.
entity
Type: System.Object
The resource to be tracked by the DataServiceContext. The resource is attached in the Unchanged state.

ExceptionCondition
ArgumentNullException

When entity or entitySetName are null.

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.

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.

Silverlight

Supported in: 5, 4, 3

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

Community Additions

ADD
Show:
© 2014 Microsoft