ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Core.Data Namespace / RelationshipCardinality Enumeration
Example Example

In This Topic
    RelationshipCardinality Enumeration
    In This Topic
    Specifies the number of rows in the origin table that can be related to a number of rows in the destination table.
    Syntax
    public enum RelationshipCardinality : System.Enum, System.IComparable, System.IConvertible, System.IFormattable  
    Public Enum RelationshipCardinality 
       Inherits System.Enum
       Implements System.IComparable, System.IConvertible, System.IFormattable 
    Members
    MemberDescription
    ManyToMany One origin row can relate to multiple destination rows and conversely, one destination row can relate to multiple origin rows.
    OneToMany One origin row can relate to multiple destination rows. In a OneToMany relationship, the origin table is always the one side and the many side must be the destination.
    OneToOne One origin row can relate to only one destination row.
    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
       System.ValueType
          System.Enum
             ArcGIS.Core.Data.RelationshipCardinality

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also