ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Core.Data Namespace / RelationshipClass Class / GetRowsRelatedToDestinationRows Method
The object IDs from the destination tables rows.
Example

In This Topic
    GetRowsRelatedToDestinationRows Method
    In This Topic
    Gets the rows from the origin table that are related to the destination row object IDs. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public IReadOnlyList<Row> GetRowsRelatedToDestinationRows( 
       IEnumerable<long> destinationObjectIDs
    )
    Public Function GetRowsRelatedToDestinationRows( _
       ByVal destinationObjectIDs As IEnumerable(Of Long) _
    ) As IReadOnlyList(Of Row)

    Parameters

    destinationObjectIDs
    The object IDs from the destination tables rows.

    Return Value

    A list with the related origin tables Rows. If destinationObjectIDs is an empty list or none of its content (i.e., OIDs) matches any row in the relationship class, an empty list will be returned.
    Exceptions
    ExceptionDescription
    destinationObjectIDs is null.
    A geodatabase-related exception has occurred.
    Remarks
    A common pattern is to generate the list of ObjectIDs from a Selection.
    Example
    Getting Rows related by RelationshipClass
    public async Task GettingRowsRelatedByRelationshipClass()
    {
      await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
      {
        using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file"))))
        using (RelationshipClass relationshipClass = geodatabase.OpenDataset<RelationshipClass>("LocalGovernment.GDB.luCodeViolationHasInspections"))
        using (FeatureClass violationsFeatureClass = geodatabase.OpenDataset<FeatureClass>("LocalGovernment.GDB.luCodeViolation"))
        using (Table inspectionTable = geodatabase.OpenDataset<Table>("LocalGovernment.GDB.luCodeInspection"))
        {
          List<Row> jeffersonAveViolations = new List<Row>();
          QueryFilter queryFilter = new QueryFilter { WhereClause = "LOCDESC LIKE '%Jefferson%'" };
    
          using (RowCursor rowCursor = violationsFeatureClass.Search(queryFilter, false))
          {
            while (rowCursor.MoveNext())
            {
              jeffersonAveViolations.Add(rowCursor.Current);
            }
          }
    
          IReadOnlyList<Row> relatedOriginRows = null;
          IReadOnlyList<Row> relatedDestinationRows = null;
    
          try
          {
            QueryFilter filter = new QueryFilter { WhereClause = "ACTION = '1st Notice'" };
    
            using (Selection selection = inspectionTable.Select(filter, SelectionType.ObjectID, SelectionOption.Normal))
            {
              relatedOriginRows = relationshipClass.GetRowsRelatedToDestinationRows(selection.GetObjectIDs());
            }
    
            bool containsJeffersonAve = relatedOriginRows.Any(row => Convert.ToString(row["LOCDESC"]).Contains("Jefferson"));
    
            List<long> jeffersonAveViolationObjectIds = jeffersonAveViolations.Select(row => row.GetObjectID()).ToList();
    
            relatedDestinationRows = relationshipClass.GetRowsRelatedToOriginRows(jeffersonAveViolationObjectIds);
            bool hasFirstNoticeInspections = relatedDestinationRows.Any(row => Convert.ToString(row["ACTION"]).Contains("1st Notice"));
          }
          finally
          {
            Dispose(jeffersonAveViolations);
            Dispose(relatedOriginRows);
            Dispose(relatedDestinationRows);
          }
        }
      });
    }
    
    private static void Dispose(IEnumerable<Row> rows)
    {
      foreach (Row row in rows)
        row.Dispose();
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also