DataServiceContext.AddLink(Object, String, Object) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds the specified link to the set of objects the DataServiceContext is tracking.
public virtual void AddLink (object source, string sourceProperty, object target);
abstract member AddLink : obj * string * obj -> unit
override this.AddLink : obj * string * obj -> unit
Public Overridable Sub AddLink (source As Object, sourceProperty As String, target As Object)
Parameters
- source
- Object
The source object for the new link.
- sourceProperty
- String
The name of the navigation property on the source object that returns the related object.
- target
- Object
The object related to the source object by the new link.
Exceptions
When source
, sourceProperty
, or target
are null.
If a link already exists.-or-If either the source
or target
objects are in a Detached or Deleted state.-or-If sourceProperty
is not a collection.
Remarks
Notifies the context that a new link exists between the source
and target
objects and that the link is represented via the source.sourceProperty
which is a collection. The context adds this link to the set of newly created links to be sent to the data service on the next call to SaveChanges(). Links are one way relationships. If a back pointer exists (ie. two way association), this method should be called a second time to notify the context object of the second link.