ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data.Knowledge Namespace / KnowledgeGraphNamedObjectType Class / GetProperties Method
Example

In This Topic
    GetProperties Method (KnowledgeGraphNamedObjectType)
    In This Topic
    Get the list of properties on this named object type. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Check Whether A Graph Type has a Spatial Property
    //Use GetDocumentEntityTypeName(KnowledgeGraphDataModel kg_dm) from
    //the 'Get Whether KG Has a Document Type' snippet to
    //get the documentNameType parameter
    protected bool HasGeometry(KnowledgeGraphNamedObjectType kg_named_obj)
    {
      var props = kg_named_obj.GetProperties();
      return props.Any(prop => prop.FieldType == FieldType.Geometry);
    }
    
    Get All KnowledgeGraph Graph Types
    QueuedTask.Run(() =>
    {
      //Create a connection properties
      var kg_props =
          new KnowledgeGraphConnectionProperties(new Uri(url));
      using (var kg = new KnowledgeGraph(kg_props))
      {
        //Get the KnowledgeGraph Data Model
        using (var kg_datamodel = kg.GetDataModel())
        {
          var entities = kg_datamodel.GetEntityTypes();
          var relationships = kg_datamodel.GetRelationshipTypes();
          var provenance = kg_datamodel.GetMetaEntityTypes();
    
          var all_graph_types = new List<KnowledgeGraphNamedObjectType>();
          all_graph_types.AddRange(entities.Values);
          all_graph_types.AddRange(relationships.Values);
          all_graph_types.AddRange(provenance.Values);
    
          System.Diagnostics.Debug.WriteLine("\r\nGraph Types");
    
          int c = 0;
          foreach (var graph_type in all_graph_types)
          {
            var type_name = graph_type.GetName();
            var role = graph_type.GetRole().ToString();
    
            //equivalent to:
            //var fields = featClassDef.GetFields().Select(f => f.Name).ToList();
            //var field_names = string.Join(",", fields);
            var props = graph_type.GetProperties().Select(p => p.Name).ToList();
            var prop_names = string.Join(",", props);
    
            System.Diagnostics.Debug.WriteLine($"[{c++}]: " +
                $"{type_name}, {role}, {prop_names}");
          }
        }
      }
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.2 or higher.
    See Also