DataServiceContext.AddLink Method
Microsoft Silverlight will reach end of support after October 2021. Learn more.
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)
Syntax
'Declaration
Public Sub AddLink ( _
source As Object, _
sourceProperty As String, _
target As Object _
)
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.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | When source, sourceProperty or target are nulla null reference (Nothing in Visual Basic). |
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. |
Remarks
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.
Examples
For an example that uses the AddLink method, see Creating New Entities with Relationships (WCF Data Services/Silverlight).
Version Information
Silverlight
Supported in: 5, 4, 3
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.