This document is archived and information here might be outdated.  Recommended version.


IRelationshipClass.CreateRelationship Method (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference (GeoDatabase)  

IRelationshipClass.CreateRelationship Method

Creates a new relationship between the two specified objects.

[Visual Basic .NET]
Public Function CreateRelationship ( _
    ByVal OriginObject As IObject, _
    ByVal DestinationObject As IObject _
) As IRelationship
[C#]
public IRelationship CreateRelationship (
    IObject OriginObject,
    IObject DestinationObject
);
[C++]
HRESULT CreateRelationship(
  IObject* OriginObject,
  IObject* DestinationObject,
  IRelationship** Relationship
);
[C++]

Parameters OriginObject [in]
OriginObject is a parameter of type IObject DestinationObject [in]
DestinationObject is a parameter of type IObject Relationship [out, retval]
Relationship is a parameter of type IRelationship

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Remarks

The CreateRelationship method creates a relationship between the origin object and the destination object specified in the parameters.  By default, when a relationship class is created, a relationship is created between the objects with corresponding primary and foreign key values.  When subsequently using CreateRelationship, remember that this operation will write a value into the foreign key field.  Therefore, in the case of 1:1 and 1:M relationship classes, it is possible that you could overwrite, and therefore delete, an existing relationship.

This method should be called within an edit session.

See Also

IRelationshipClass Interface