ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data.DDL.Knowledge Namespace / KnowledgeGraphPropertyDescription Class / CreateStringProperty Method
The name of the ArcGIS.Core.Data.Field to create.
The length of the ArcGIS.Core.Data.Field to create.
Example

In This Topic
    CreateStringProperty Method
    In This Topic
    Creates a property description of ArcGIS.Core.Data.FieldType string.
    Syntax
    public static KnowledgeGraphPropertyDescription CreateStringProperty( 
       string name,
       int length
    )
    Public Shared Function CreateStringProperty( _
       ByVal name As String, _
       ByVal length As Integer _
    ) As KnowledgeGraphPropertyDescription

    Parameters

    name
    The name of the ArcGIS.Core.Data.Field to create.
    length
    The length of the ArcGIS.Core.Data.Field to create.

    Return Value

    A property description for a string ArcGIS.Core.Data.Knowledge.KnowledgeGraphProperty.
    Exceptions
    ExceptionDescription
    The description name has an invalid character
    Example
    Modify Entity and Relationship Type Schemas with SchemaBuilder
    await QueuedTask.Run(() =>
    {
      using (var kg = GetKnowledgeGraph())
      {
        if (kg == null)
          return;
    
        var entity_name = "PhoneCall";
        var relate_name = "WhoCalledWho";
    
        var kvp_entity = kg.GetDataModel().GetEntityTypes()
             .First(r => r.Key == entity_name);
        var kvp_relate = kg.GetDataModel().GetRelationshipTypes()
                       .First(r => r.Key == relate_name);
    
        //Let's delete one field and add a new one from each
        //A field gets deleted implicitly if it is not included in the list of
        //fields - or "properties" in this case....so we will remove the last
        //property from the list
        var entity_props = kvp_entity.Value.GetProperties().Reverse().Skip(1).Reverse();
        var prop_descs = new List<KnowledgeGraphPropertyDescription>();
    
        foreach (var prop in entity_props)
        {
          if (prop.FieldType == FieldType.Geometry)
          {
            continue;//skip shape
          }
          var prop_desc = new KnowledgeGraphPropertyDescription(prop);
          prop_descs.Add(prop_desc);
        }
        //deal with shape - we need to keep it
        //SchemaBuilder deletes any field not included in the "modify" list
        ShapeDescription shape_desc = null;
        if (kvp_entity.Value.GetIsSpatial())
        {
          var geom_def = kvp_entity.Value.GetShapeDefinition();
          var shape_name = kvp_entity.Value.GetShapeField();
          shape_desc = new ShapeDescription(
            shape_name, geom_def.geometryType, geom_def.sr);
        }
        //add the new entity property
        prop_descs.Add(
          KnowledgeGraphPropertyDescription.CreateStringProperty("foo", 10));
        //make a description for the entity type - ok if shape_desc is null
        var entityDesc = new KnowledgeGraphEntityTypeDescription(
          entity_name, prop_descs, shape_desc);
    
        //Add the entity type description to the schema builder using 'Modify'
        SchemaBuilder sb = new(kg);
        sb.Modify(entityDesc);
    
        //Repeat for the relationship - assuming we have at least one custom attribute field
        //that can be deleted on our relationship schema...
        var rel_props = kvp_relate.Value.GetProperties().Reverse().Skip(1).Reverse();
        var rel_prop_descs = new List<KnowledgeGraphPropertyDescription>();
    
        foreach (var prop in rel_props)
        {
          if (prop.FieldType == FieldType.Geometry)
          {
            continue;//skip shape
          }
          var prop_desc = new KnowledgeGraphPropertyDescription(prop);
          rel_prop_descs.Add(prop_desc);
        }
        //deal with shape - we need to keep it
        //SchemaBuilder deletes any field not included in the "modify" list
        ShapeDescription shape_desc_rel = null;
        if (kvp_relate.Value.GetIsSpatial())
        {
          var geom_def = kvp_relate.Value.GetShapeDefinition();
          var shape_name = kvp_relate.Value.GetShapeField();
          shape_desc_rel = new ShapeDescription(
            shape_name, geom_def.geometryType, geom_def.sr);
        }
        //add a new relationship property
        rel_prop_descs.Add(
          KnowledgeGraphPropertyDescription.CreateStringProperty("bar", 10));
        //make a description for the relationship type - ok if shape_desc is null
        var relDesc = new KnowledgeGraphRelationshipTypeDescription(
          relate_name, rel_prop_descs, shape_desc_rel);
    
        //Add the relationship type description to the schema builder using 'Modify'
        sb.Modify(relDesc);
    
        //Run the schema builder
        try
        {
          //Use the KnowledgeGraph extension method 'ApplySchemaEdits(...)'
          //to refresh the Pro UI
          if (!kg.ApplySchemaEdits(sb))
          {
            var err_msg = string.Join(",", sb.ErrorMessages.ToArray());
            System.Diagnostics.Debug.WriteLine($"Entity/Relate Modify error: {err_msg}");
          }
        }
        catch (Exception ex)
        {
          System.Diagnostics.Debug.WriteLine(ex.ToString());
        }
      }
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.4 or higher.
    See Also