Export (0) Print
Expand All

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
)

Parameters

source
Type: System.Object
The source object for the new link.
sourceProperty
Type: System.String
The property on the source object that identifies the object to which the source adds a link.
target
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.

ExceptionCondition
ArgumentNullException

When source, sourceProperty or target are null.

InvalidOperationException

When the link already exists.

-or-

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

-or-

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.

Silverlight

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

ADD
Show:
© 2015 Microsoft