DataServiceContext.AddLink Method

Adds the specified link to the set of objects the DataServiceContext is tracking.

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

public void AddLink(
	Object source,
	string sourceProperty,
	Object target


Type: System.Object
The source object for the new link.
Type: System.String
The name of the navigation property on the source object that returns the related object.
Type: System.Object
The object related to the source object by the new link.


When source, sourceProperty, or target are null.


If a link already exists.


If either the source or target objects are in a Detached or Deleted state.


If sourceProperty is not a collection.

Notifies the DataServiceContext that a new link exists between the related source and target objects and that the link is represented by the specified source property. The DataServiceContext adds this link to the set of newly created links that will be sent to the data service on the next call to SaveChanges. For more information, see Updating the Data Service (WCF Data Services).

The target object must be of the type identified by the sourceProperty parameter or a subtype of the type.