ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Core.Data Namespace / AttributedRelationshipClass Class / CreateRelationship Method / CreateRelationship(Row,Row) Method
The Row from the origin table.
The Row from the destination table.

In This Topic
    CreateRelationship(Row,Row) 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 new AttributedRelationship CreateRelationship( 
       Row originRow,
       Row destinationRow
    )
    Public Overloads Shadows Function CreateRelationship( _
       ByVal originRow As Row, _
       ByVal destinationRow As Row _
    ) As AttributedRelationship

    Parameters

    originRow
    The Row from the origin table.
    destinationRow
    The Row from the destination table.

    Return Value

    An AttributedRelationship representing the pair of related rows.
    Exceptions
    ExceptionDescription
    originRow or destinationRow 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 foreign and destination foreign key values.

    When calling CreateRelationship(Row,Row) on an intermediate table that has user-defined attributes defined, 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. However, all the user-defined fields will remain unpopulated. To populate the user-defined fields in the intermediate table, you should use the overloaded CreateRelationship(Row,Row,RowBuffer) instead.

    For relationships of type RelationshipCardinality.ManyToMany that do not have user-defined attributes, you should use this version rather than CreateRelationship(Row,Row,RowBuffer) since there are no additional attributes to be populated in the intermediate table.

    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also