Share via


DataServiceContext.AttachTo Method

Definition

Overloads

AttachTo(String, Object)

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

AttachTo(String, Object, String)

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

AttachTo(String, Object)

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

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

Parameters

entitySetName
String

The name of the set that contains the resource.

entity
Object

The resource to be tracked by the DataServiceContext. The resource is attached in the Unchanged state.

Exceptions

When entity or entitySetName is null.

When entitySetName is an empty string.-or-When the entity does not have a key property defined.

When the entity is already being tracked by the context.

Remarks

It does not follow the object graph and attach related objects.

Applies to

AttachTo(String, Object, String)

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

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

Parameters

entitySetName
String

The string value that contains the name of the entity set to which to the entity is attached.

entity
Object

The entity to add.

etag
String

An etag value that represents the state of the entity the last time it was retrieved from the data service. This value is treated as an opaque string; no validation is performed on it by the client library.

Exceptions

When entitySetName is null.-or-When entity is null.

When entitySetName is an empty string.-or-When the supplied object does not have a key property.

When the supplied object is already being tracked by the context

Remarks

It does not follow the object graph and attach related objects.

Applies to