Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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)
Syntax
'Declaration
Public Sub AttachTo ( _
entitySetName As String, _
entity As Object _
)
'Usage
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
)
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.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | When entity or entitySetName is nulla null reference (Nothing in Visual Basic). |
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. |
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 occurs in the data service associated with the DataServiceContext.