DataServiceContext.AddLink Method

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

Namespace:  System.Data.Services.Client
Assembly:  System.Data.Services.Client (in System.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 property on the source object that identifies the object to which the source adds a link.
Type: System.Object
The object in the new link to which the source will be linked. The target object must be of the type identified by the sourceProperty parameter or a subtype of the type.


When source, sourceProperty or target are null.


When the link already exists.


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


When sourceProperty is not property that returns a collection.

Notifies the DataServiceContext that a new link exists between the source and target objects specified and that the link is represented by the source property specified. 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 BeginSaveChanges.

Links are one-way relationships. If a back pointer exists, as in a two-way association, this method must be called again to notify the DataServiceContext object of the second link.


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