ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Core.Data.DDL Namespace / AttributedRelationshipClassDescription Class / FieldDescriptions Property
Example

In This Topic
    FieldDescriptions Property (AttributedRelationshipClassDescription)
    In This Topic
    The fields to add to the intermediate relationship class table.
    Syntax
    public List<FieldDescription> FieldDescriptions {get;}
    Public ReadOnly Property FieldDescriptions As List(Of FieldDescription)
    Example
    Creating attributed relationship class
    {
      Task CreateAttributedRelationshipAsync(SchemaBuilder schemaBuilder) => QueuedTask.Run(() =>
      {
        // Creating a 'BuildingType' table with two fields - BuildingType and BuildingTypeDescription
        FieldDescription buildingType = FieldDescription.CreateIntegerField("BuildingType");
        FieldDescription buildingTypeeDescription = FieldDescription.CreateStringField("BuildingTypeDescription", 100);
        TableDescription buildingTypeDescription = new TableDescription("BuildingType",
          new List<FieldDescription>() { buildingType, buildingTypeeDescription });
        TableToken buildingtypeToken = schemaBuilder.Create(buildingTypeDescription);
    
        // Creating a 'Building' feature class with three fields - BuildingId, Address, and BuildingType
        FieldDescription buildingId = FieldDescription.CreateIntegerField("BuildingId");
        FieldDescription buildingAddress = FieldDescription.CreateStringField("Address", 100);
        FeatureClassDescription featureClassDescription = new FeatureClassDescription("Building",
          new List<FieldDescription> { buildingId, buildingAddress, buildingType },
          new ShapeDescription(GeometryType.Polygon, SpatialReferences.WGS84));
        FeatureClassToken buildingToken = schemaBuilder.Create(featureClassDescription);
    
        // Creating M:M relationship between the 'Building' feature class and 'BuildingType' table
        AttributedRelationshipClassDescription attributedRelationshipClassDescription =
          new AttributedRelationshipClassDescription("BuildingToBuildingType",
            new FeatureClassDescription(buildingToken),
            new TableDescription(buildingtypeToken), RelationshipCardinality.ManyToMany, "OBJECTID", "BuildingID",
            "OBJECTID", "BuildingTypeID");
    
        // Adding optional attribute field in the intermediate table - 'OwnershipPercentage' field
        attributedRelationshipClassDescription.FieldDescriptions.Add(FieldDescription.CreateIntegerField("OwnershipPercentage"));
    
        schemaBuilder.Create(attributedRelationshipClassDescription);
        schemaBuilder.Build();
      });
    }
    Add relationship rules to a relationship class
    {
      Task ModifyRelationshipClassAsync(SchemaBuilder schemaBuilder, AttributedRelationshipClassDefinition attributedRelationshipClassDefinition) => QueuedTask.Run(() =>
      {
        AttributedRelationshipClassDescription attributedRelationshipClassDescription = new AttributedRelationshipClassDescription(attributedRelationshipClassDefinition);
    
        // Update the relationship split policy
        attributedRelationshipClassDescription.RelationshipSplitPolicy = RelationshipSplitPolicy.UseDefault;
    
        // Add field in the intermediate table
        attributedRelationshipClassDescription.FieldDescriptions.Add(FieldDescription.CreateIntegerField("RelationshipStatus"));
    
        // Add relationship rules based on subtypes,if available
        // Assuming origin class has subtype with code 1
        attributedRelationshipClassDescription.RelationshipRuleDescriptions.Add(
          new RelationshipRuleDescription(1, null));
    
        // Enqueue modify operation
        schemaBuilder.Modify(attributedRelationshipClassDescription);
    
        // Execute modify DDL operation
        schemaBuilder.Build();
      });
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.1 or higher.
    See Also