ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Data.DDL Namespace / SchemaBuilder Class / Modify Method / Modify(TableDescription) Method
Indicates the ArcGIS.Core.Data.Table to be modified.
Example

In This Topic
    Modify(TableDescription) Method
    In This Topic
    Enqueue the modify operation on the object referred to by the TableDescription. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Overloads Sub Modify( _
       ByVal tableDescription As TableDescription _
    ) 
    public void Modify( 
       TableDescription tableDescription
    )

    Parameters

    tableDescription
    Indicates the ArcGIS.Core.Data.Table to be modified.
    Exceptions
    ExceptionDescription
    The subtypes are invalid.
    tableDescription is null.
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Removing fields from a Table
    {
      // Must be called within QueuedTask.Run
      void RemoveFieldTableSnippet(Geodatabase geodatabase)
      {
        // Removing all fields from 'Parcels' table except following 
        // Tax_Code
        // Parcel_Address
    
        // The table to remove fields
        string tableName = "Parcels";
    
        TableDefinition tableDefinition = geodatabase.GetDefinition<TableDefinition>(tableName);
        IReadOnlyList<Field> fields = tableDefinition.GetFields();
    
        // Existing fields from 'Parcels' table
        Field taxCodeField = fields.First(f => f.Name.Equals("Tax_Code"));
        Field parcelAddressField = fields.First(f => f.Name.Equals("Parcel_Address"));
    
        FieldDescription taxFieldDescription = new FieldDescription(taxCodeField);
        FieldDescription parcelAddressFieldDescription = new FieldDescription(parcelAddressField);
    
        // Fields to retain in modified table
        List<FieldDescription> fieldsToBeRetained = new List<FieldDescription>()
          {
            taxFieldDescription, parcelAddressFieldDescription
          };
    
        // New description of the 'Parcels' table with the 'Tax_Code' and 'Parcel_Address' fields
        TableDescription modifiedTableDescription = new TableDescription(tableName, fieldsToBeRetained);
    
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Remove all fields except the 'Tax_Code' and 'Parcel_Address' fields
        schemaBuilder.Modify(modifiedTableDescription);
        schemaBuilder.Build();
      }
    }
    Modifying domain
    {
      // Must be called within QueuedTask.Run
      void ModifyDomain(Geodatabase geodatabase, string codedValueDomainName = "Pipe")
      {
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
        CodedValueDomain codedValueDomain = geodatabase.GetDomains().First(f => f.GetName().Equals(codedValueDomainName)) as CodedValueDomain;
        CodedValueDomainDescription codedValueDomainDescription = new CodedValueDomainDescription(codedValueDomain);
    
        // Update domain description
        codedValueDomainDescription.Description = "Water Pipe Domain";
    
        // Adding code/value pair
        codedValueDomainDescription.CodedValuePairs.Add("C", "Copper");
    
        schemaBuilder.Modify(codedValueDomainDescription);
    
        // To modify the orders of coded value domain
        // schemaBuilder.Modify(codedValueDomainDescription,SortBy.Name,SortOrder.Ascending);
    
        schemaBuilder.Build();
      }
    }
    Removing subtype field designation
    {
      // Must be called within QueuedTask.Run
      void DeleteSubtypeField(SchemaBuilder schemaBuilder, FeatureClassDefinition featureClassDefinition)
      {
        FeatureClassDescription featureClassDescription = new FeatureClassDescription(featureClassDefinition);
    
        // Set subtype field to null to remove the subtype field designation 
        featureClassDescription.SubtypeFieldDescription = null;
    
        schemaBuilder.Modify(featureClassDescription);
        schemaBuilder.Build();
      }
    }
    Modifying subtypes
    {
      // Must be called within QueuedTask.Run
      void ModifySubtypes(SchemaBuilder schemaBuilder, TableDefinition tableDefinition)
      {
        TableDescription tableDescription = new TableDescription(tableDefinition);
    
        // Remove the first subtype from the table
        IReadOnlyList<Subtype> subtypes = tableDefinition.GetSubtypes();
        tableDescription.SubtypeFieldDescription.Subtypes.Remove(subtypes.First().GetCode());
    
        // Adding a new subtype, 'Utility', in the existing table
        tableDescription.SubtypeFieldDescription.Subtypes.Add(4, "Utility");
    
        // Assigning 'Utility' subtype as the default subtype
        tableDescription.SubtypeFieldDescription.DefaultSubtypeCode = 4;
    
        schemaBuilder.Modify(tableDescription);
        schemaBuilder.Build();
      }
    }
    Add relationship rules to a relationship class
    {
      // Must be called within QueuedTask.Run
      void ModifyRelationshipClass(SchemaBuilder schemaBuilder, AttributedRelationshipClassDefinition attributedRelationshipClassDefinition)
      {
        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();
      }
    }
    Modifying annotation labels and symbols
    {
      // Must be called within QueuedTask.Run
      void ModifyAnnotationLabelAndSymbols(SchemaBuilder schemaBuilder, AnnotationFeatureClassDefinition annotationFeatureClassDefinition)
      {
        AnnotationFeatureClassDescription annotationFeatureClassDescription = new AnnotationFeatureClassDescription(annotationFeatureClassDefinition);
        IReadOnlyList<CIMLabelClass> labelClasses = annotationFeatureClassDescription.LabelClasses;
    
        // Adding a new annotation label class 
        List<CIMLabelClass> modifiedLabelClasses = new List<CIMLabelClass>(labelClasses);
        modifiedLabelClasses.Add(new CIMLabelClass()
        {
          Name = "RedSymbol",
          TextSymbol = new CIMSymbolReference
          {
            Symbol = new CIMTextSymbol()
            {
              Angle = 45,
              FontType = FontType.Type1,
              FontFamilyName = "Arial",
              FontEffects = FontEffects.Normal,
              HaloSize = 2.0,
    
              Symbol = new CIMPolygonSymbol
              {
                SymbolLayers = new CIMSymbolLayer[]
                  { new CIMSolidFill { Color = CIMColor.CreateRGBColor(255, 0, 0) } },
                UseRealWorldSymbolSizes = true
              }
            },
            MaxScale = 0,
            MinScale = 0,
            SymbolName = "TextSymbol-RED"
          }
        });
    
        // Adding a  new symbol
        annotationFeatureClassDescription.Symbols.Add(new CIMSymbolIdentifier()
        {
          ID = 1001,
          Name = "ID_10001",
          Symbol = new CIMTextSymbol()
          {
            Angle = 43,
            FontEffects = FontEffects.Subscript,
            FontType = FontType.TTOpenType,
            FontStyleName = "Regular",
            FontFamilyName = "Tahoma",
            TextCase = TextCase.Allcaps
          }
        });
    
        // Modify annotation feature class 
        AnnotationFeatureClassDescription modifiedAnnotationFeatureClassDescription = new AnnotationFeatureClassDescription(annotationFeatureClassDescription.Name,
            annotationFeatureClassDescription.FieldDescriptions, annotationFeatureClassDescription.ShapeDescription,
            annotationFeatureClassDescription.GeneralPlacementProperties, modifiedLabelClasses);
    
        // Enqueue modify
        schemaBuilder.Modify(modifiedAnnotationFeatureClassDescription);
    
        // DDL execute
        schemaBuilder.Build();
      }
    }
    Modifying an existing field
    {
      // Must be called within QueuedTask.Run
      void ModifyExistingField(SchemaBuilder schemaBuilder, TableDefinition tableDefinition, string fieldNameToBeModified = "PropertyAddress")
      {
        Field field = tableDefinition.GetFields().FirstOrDefault(f => f.Name.Contains(fieldNameToBeModified));
    
        // Update field's alias name and length
        FieldDescription fieldDescription = new FieldDescription(field)
        {
          AliasName = "Physical Property Address",
          Length = 50
        };
    
        // Update the default value
        fieldDescription.SetDefaultValue("123 Main St");
    
        // Enqueue modify operation
        schemaBuilder.Modify(new TableDescription(tableDefinition), field.Name, fieldDescription);
    
        // Execute DDL
        schemaBuilder.Build();
      }
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also