ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data.DDL Namespace / FieldDescription Class / FieldDescription Constructor / FieldDescription Constructor(String,FieldType)
The name of the description.
The ArcGIS.Core.Data.FieldType for the ArcGIS.Core.Data.Field.
Example

In This Topic
    FieldDescription Constructor(String,FieldType)
    In This Topic
    Creates a description object of the ArcGIS.Core.Data.Field.
    Syntax
    public FieldDescription( 
       string name,
       FieldType fieldType
    )
    Public Function New( _
       ByVal name As String, _
       ByVal fieldType As FieldType _
    )

    Parameters

    name
    The name of the description.
    fieldType
    The ArcGIS.Core.Data.FieldType for the ArcGIS.Core.Data.Field.
    Exceptions
    ExceptionDescription
    name and/or fieldType is invalid.
    fieldType is not supported.
    Example
    Creating a Table
    public void CreateTableSnippet(Geodatabase geodatabase, CodedValueDomain inspectionResultsDomain)
    {
        // Create a PoleInspection table with the following fields
        //  GlobalID
        //  ObjectID
        //  InspectionDate (date)
        //  InspectionResults (pre-existing InspectionResults coded value domain)
        //  InspectionNotes (string)
    
        // This static helper routine creates a FieldDescription for a GlobalID field with default values
        FieldDescription globalIDFieldDescription = FieldDescription.CreateGlobalIDField();
    
        // This static helper routine creates a FieldDescription for an ObjectID field with default values
        FieldDescription objectIDFieldDescription = FieldDescription.CreateObjectIDField();
    
        // Create a FieldDescription for the InspectionDate field
        FieldDescription inspectionDateFieldDescription = new FieldDescription("InspectionDate", FieldType.Date)
        {
            AliasName = "Inspection Date"
        };
    
        // This static helper routine creates a FieldDescription for a Domain field (from a pre-existing domain)
        FieldDescription inspectionResultsFieldDescription = FieldDescription.CreateDomainField("InspectionResults", new CodedValueDomainDescription(inspectionResultsDomain));
        inspectionResultsFieldDescription.AliasName = "Inspection Results";
    
        // This static helper routine creates a FieldDescription for a string field
        FieldDescription inspectionNotesFieldDescription = FieldDescription.CreateStringField("InspectionNotes", 512);
        inspectionNotesFieldDescription.AliasName = "Inspection Notes";
    
        // Assemble a list of all of our field descriptions
        List<FieldDescription> fieldDescriptions = new List<FieldDescription>()
    { globalIDFieldDescription, objectIDFieldDescription, inspectionDateFieldDescription, inspectionResultsFieldDescription, inspectionNotesFieldDescription };
    
        // Create a TableDescription object to describe the table to create
        TableDescription tableDescription = new TableDescription("PoleInspection", fieldDescriptions);
    
        // Create a SchemaBuilder object
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Add the creation of PoleInspection to our list of DDL tasks
        schemaBuilder.Create(tableDescription);
    
        // Execute the DDL
        bool success = schemaBuilder.Build();
    
        // Inspect error messages
        if (!success)
        {
            IReadOnlyList<string> errorMessages = schemaBuilder.ErrorMessages;
            //etc.
        }
    }
    Creating a feature class
    public void CreateFeatureClassSnippet(Geodatabase geodatabase, FeatureClass existingFeatureClass, SpatialReference spatialReference)
    {
        // Create a Cities feature class with the following fields
        //  GlobalID
        //  ObjectID
        //  Name (string)
        //  Population (integer)
    
        // This static helper routine creates a FieldDescription for a GlobalID field with default values
        FieldDescription globalIDFieldDescription = FieldDescription.CreateGlobalIDField();
    
        // This static helper routine creates a FieldDescription for an ObjectID field with default values
        FieldDescription objectIDFieldDescription = FieldDescription.CreateObjectIDField();
    
        // This static helper routine creates a FieldDescription for a string field
        FieldDescription nameFieldDescription = FieldDescription.CreateStringField("Name", 255);
    
        // This static helper routine creates a FieldDescription for an integer field
        FieldDescription populationFieldDescription = FieldDescription.CreateIntegerField("Population");
    
        // Assemble a list of all of our field descriptions
        List<FieldDescription> fieldDescriptions = new List<FieldDescription>()
    { globalIDFieldDescription, objectIDFieldDescription, nameFieldDescription, populationFieldDescription };
    
        // Create a ShapeDescription object
        ShapeDescription shapeDescription = new ShapeDescription(GeometryType.Point, spatialReference);
    
        // Alternatively, ShapeDescriptions can be created from another feature class.  In this case, the new feature class will inherit the same shape properties of the existing class
        ShapeDescription alternativeShapeDescription = new ShapeDescription(existingFeatureClass.GetDefinition());
    
        // Create a FeatureClassDescription object to describe the feature class to create
        FeatureClassDescription featureClassDescription =
          new FeatureClassDescription("Cities", fieldDescriptions, shapeDescription);
    
        // Create a SchemaBuilder object
        SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
        // Add the creation of the Cities feature class to our list of DDL tasks
        schemaBuilder.Create(featureClassDescription);
    
        // Execute the DDL
        bool success = schemaBuilder.Build();
    
        // Inspect error messages
        if (!success)
        {
            IReadOnlyList<string> errorMessages = schemaBuilder.ErrorMessages;
            //etc.
        }
    }
    Create Domain and Field Definition on KG Schemas with SchemaBuilder
        await QueuedTask.Run(() =>
        {
          using (var kg = GetKnowledgeGraph())
          {
            if (kg == null)
              return;
    
            var entity_name = "Fruit";
    
            //Domains are managed on the GDB objects...
            var fruit_fc = kg.OpenDataset<FeatureClass>(entity_name);
            var fruit_fc_def = fruit_fc.GetDefinition();
    
            var fieldFruitTypes = fruit_fc_def.GetFields()
                  .FirstOrDefault(f => f.Name == "FruitTypes");
            var fieldShelfLife = fruit_fc_def.GetFields()
                .FirstOrDefault(f => f.Name == "ShelfLife");
    
            //Create a coded value domain and add it to a new field
            var fruit_cvd_desc = new CodedValueDomainDescription(
              "FruitTypes", FieldType.String, 
              new SortedList<object, string> {
                              { "A", "Apple" },
                              { "B", "Banana" },
                              { "C", "Coconut" }
              })  {
                SplitPolicy = SplitPolicy.Duplicate,
                MergePolicy = MergePolicy.DefaultValue
            };
    
            //Create a Range Domain and add the domain to a new field description also
            var shelf_life_rd_desc = new RangeDomainDescription(
                                          "ShelfLife", FieldType.Integer, 0, 14);
    
            var sb = new SchemaBuilder(kg);
            sb.Create(fruit_cvd_desc);
            sb.Create(shelf_life_rd_desc);
    
            //Create the new field descriptions that will be associated with the
            //"new" FruitTypes coded value domain and the ShelfLife range domain
            var fruit_types_fld = new ArcGIS.Core.Data.DDL.FieldDescription(
                                          "FruitTypes", FieldType.String);
            fruit_types_fld.SetDomainDescription(fruit_cvd_desc);
    
            //ShelfLife will use the range domain
            var shelf_life_fld = new ArcGIS.Core.Data.DDL.FieldDescription(
    "ShelfLife", FieldType.Integer);
            shelf_life_fld.SetDomainDescription(shelf_life_rd_desc);
    
            //Add the descriptions to the list of field descriptions for the
            //fruit feature class - Modify schema needs _all_ fields to be included
            //in the schema, not just the new ones to be added.
            var fruit_fc_desc = new FeatureClassDescription(fruit_fc_def);
    
            var modified_fld_descs = new List<ArcGIS.Core.Data.DDL.FieldDescription>(
              fruit_fc_desc.FieldDescriptions);
    
            modified_fld_descs.Add(fruit_types_fld);
            modified_fld_descs.Add(shelf_life_fld);
    
            //Create a feature class description to modify the fruit entity
            //with the new fields and their associated domains
            var updated_fruit_fc =
              new FeatureClassDescription(entity_name, modified_fld_descs,
                                          fruit_fc_desc.ShapeDescription);
    
            //Add the modified fruit fc desc to the schema builder
            sb.Modify(updated_fruit_fc);
    
            //Run the schema builder
            try
            {
              if (!kg.ApplySchemaEdits(sb))
              {
                var err_msg = string.Join(",", sb.ErrorMessages.ToArray());
                System.Diagnostics.Debug.WriteLine($"Create domains error: {err_msg}");
              }
            }
            catch (Exception ex)
            {
              System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
          }
        });
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also