ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Data.DDL Namespace / SubtypeFieldDescription Class / SubtypeFieldDescription Constructor
The name of the subtype field.
The code-name pairs of the subtypes.
Example

In This Topic
    SubtypeFieldDescription Constructor
    In This Topic
    Creates a description object of the subtype ArcGIS.Core.Data.Field.
    Syntax
    public SubtypeFieldDescription( 
       string subtypeFieldName,
       Dictionary<int,string> subtypes
    )
    Public Function New( _
       ByVal subtypeFieldName As String, _
       ByVal subtypes As Dictionary(Of Integer,String) _
    )

    Parameters

    subtypeFieldName
    The name of the subtype field.
    subtypes
    The code-name pairs of the subtypes.
    Exceptions
    ExceptionDescription
    subtypeFieldName and/or subtypes is null.
    Example
    Creating table with subtypes
    public void CreateTableWithSubtypes(SchemaBuilder schemaBuilder)
    {
      // Creating a 'Building' table with the subtype field 'BuildingType'
      FieldDescription buildingType = new FieldDescription("BuildingType", FieldType.Integer);
      FieldDescription buildingName = new FieldDescription("Name", FieldType.String);
    
      TableDescription tableDescription = new TableDescription("Building", new List<FieldDescription> { buildingName, buildingType });
    
      // Add the building type subtype with three subtypes - Business, Marketing, Security
      tableDescription.SubtypeFieldDescription = new SubtypeFieldDescription(buildingType.Name, new Dictionary<int, string> { { 1, "Business" }, { 2, "Marketing" }, { 3, "Security" } })
      {
        DefaultSubtypeCode = 3 // Assigning 'Security' building type as the default subtype
      };
    
      schemaBuilder.Create(tableDescription);
      schemaBuilder.Build();
    }
    Creating relationship class
    public void CreateRelationshipWithRelationshipRules(SchemaBuilder schemaBuilder)
    {
      // 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);
      FieldDescription usageSubType = FieldDescription.CreateIntegerField("UsageSubtype");
      FeatureClassDescription featureClassDescription = new FeatureClassDescription("Building", new List<FieldDescription> { buildingId, buildingAddress, buildingType, usageSubType }, new ShapeDescription(GeometryType.Polygon, SpatialReferences.WGS84));
    
      // Set subtype details (optional)
      featureClassDescription.SubtypeFieldDescription = new SubtypeFieldDescription(usageSubType.Name, new Dictionary<int, string> { { 1, "Marketing" }, { 2, "Utility" } });
    
      FeatureClassToken buildingToken = schemaBuilder.Create(featureClassDescription);
    
      // Creating a 1:M relationship between the 'Building' feature class and 'BuildingType' table
      RelationshipClassDescription relationshipClassDescription = new RelationshipClassDescription("BuildingToBuildingType", new FeatureClassDescription(buildingToken), new TableDescription(buildingtypeToken),
        RelationshipCardinality.OneToMany, buildingType.Name, buildingType.Name)
      {
        RelationshipType = RelationshipType.Composite
      };
    
      // Adding relationship rules for the 'Marketing' subtype
      relationshipClassDescription.RelationshipRuleDescriptions.Add(new RelationshipRuleDescription(1, null));
    
      schemaBuilder.Create(relationshipClassDescription);
      schemaBuilder.Build();
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.1 or higher.
    See Also