ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data Namespace / RelationshipClass Class
Members Example

In This Topic
    RelationshipClass Class
    In This Topic
    Represents an association between two tables in a geodatabase.
    Object Model
    RelationshipClass ClassRelationship ClassDatastore ClassRelationshipClassDefinition ClassFeatureDataset Class
    Syntax
    public class RelationshipClass : Dataset, System.IDisposable  
    Public Class RelationshipClass 
       Inherits Dataset
       Implements System.IDisposable 
    Remarks
    The primary difference between a RelationshipClass and AttributedRelationshipClass is that a RelationshipClass does not have an intermediate table.
    Example
    Joining a file geodatabase feature class to an Oracle database query layer feature class with a virtual relationship class
    public async Task JoiningFileGeodatabaseFeatureClassToOracleQueryLayer()
    {
        await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
        {
            using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri("C:\\Data\\LocalGovernment.gdb"))))
            using (Database database = new Database(new DatabaseConnectionProperties(EnterpriseDatabaseType.Oracle)
            {
                AuthenticationMode = AuthenticationMode.DBMS,
                Instance = "instance",
                User = "user",
                Password = "password",
                Database = "database"
            }))
    
            using (FeatureClass leftFeatureClass = geodatabase.OpenDataset<FeatureClass>("Hospital"))
            using (Table rightTable = database.OpenTable(database.GetQueryDescription("FacilitySite")))
            {
                Field originPrimaryKey = leftFeatureClass.GetDefinition().GetFields().FirstOrDefault(field => field.Name.Equals("facilityId"));
                Field destinationForeignKey = rightTable.GetDefinition().GetFields().FirstOrDefault(field => field.Name.Equals("hospitalID"));
    
                VirtualRelationshipClassDescription description = new VirtualRelationshipClassDescription(
            originPrimaryKey, destinationForeignKey, RelationshipCardinality.OneToOne);
    
                using (RelationshipClass relationshipClass = leftFeatureClass.RelateTo(rightTable, description))
                {
                    JoinDescription joinDescription = new JoinDescription(relationshipClass)
                    {
                        JoinDirection = JoinDirection.Forward,
                        JoinType = JoinType.LeftOuterJoin
                    };
    
                    Join join = new Join(joinDescription);
    
                    using (Table joinedTable = join.GetJoinedTable())
                    {
                        // Perform operation on joined table.
                    }
                }
            }
        });
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.CoreObjectsBase
          ArcGIS.Core.Data.Dataset
             ArcGIS.Core.Data.RelationshipClass
                ArcGIS.Core.Data.AttributedRelationshipClass

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also