ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Core.Data Namespace / AttributedRelationshipClass Class / CreateRelationship Method / CreateRelationship(Row,Row,RowBuffer) Method
The Row from the origin table.
The Row from the destination table.
A RowBuffer created from the CreateRowBuffer method and populated with desired values.

In This Topic
    CreateRelationship(Row,Row,RowBuffer) Method
    In This Topic
    Creates a new relationship between the two specified rows and/or features. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Overloads Function CreateRelationship( _
       ByVal originRow As Row, _
       ByVal destinationRow As Row, _
       ByVal attributes As RowBuffer _
    ) As AttributedRelationship

    Parameters

    originRow
    The Row from the origin table.
    destinationRow
    The Row from the destination table.
    attributes
    A RowBuffer created from the CreateRowBuffer method and populated with desired values.

    Return Value

    An AttributedRelationship representing the pair of related rows.
    Exceptions
    ExceptionDescription
    originRow, destinationRow or attributes is null.
    A geodatabase-related exception has occurred.
    Remarks

    For relationships of type RelationshipCardinality.OneToOne, RelationshipCardinality.OneToMany and RelationshipCardinality.ManyToMany that have user-attributes defined (vs. system generated), an intermediate table will be created to store relationships between the rows with corresponding origin and destination foreign key values.

    When calling CreateRelationship(Row,Row,RowBuffer), the origin row's primary key value will be written into the field specified by AttributedRelationshipClassDefinition.GetDestinationKeyField in the intermediate table. Likewise, the destination row's primary key value will be written into the field specified by AttributedRelationshipClassDefinition.GetDestinationForeignKeyField in the intermediate table. Therefore it is possible that you could overwrite, and therefore delete, an existing relationship. The rest of the attributes values in attributes with be written to the corresponding user-defined fields in the intermediate table.

    For relationships of type RelationshipCardinality.ManyToMany that do not have user-attributes defined (hence, the intermedidate table has only system-generated fields), attributes has no effect on the intermediate table.

    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also