SALES: 1-800-867-1380
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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:  Microsoft.Data.Services.Client (in Microsoft.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 is null.

ArgumentException

When entitySetName is an empty string.

-or-

When the entity does not have a key property defined.

InvalidOperationException

When the 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 occurs in the data service associated with the DataServiceContext.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft