ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Data.Knowledge Namespace / KnowledgeGraph Class / GetDataModel Method
Example

In This Topic
    GetDataModel Method
    In This Topic
    Gets the KnowledgeGraphDataModel for the knowledge graph. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function GetDataModel() As KnowledgeGraphDataModel
    public KnowledgeGraphDataModel GetDataModel()

    Return Value

    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Retrieving the Data Model
    {
      await 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_dm = kg.GetDataModel())
          {
            //TODO use KG data model...
          }
        }
      });
    }
    Get Data Model Properties
    {
      await 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_dm = kg.GetDataModel())
          {
            var kg_name = System.IO.Path.GetFileName(
                     System.IO.Path.GetDirectoryName(kg_props.PathOrURL.ToString()));
    
            System.Diagnostics.Debug.WriteLine(
              $"\r\n'{kg_name}' Datamodel:\r\n-----------------");
            var time_stamp = kg_dm.GetTimestamp();
            var sr = kg_dm.GetSpatialReference();
            System.Diagnostics.Debug.WriteLine($"Timestamp: {time_stamp}");
            System.Diagnostics.Debug.WriteLine($"Sref: {sr.Wkid}");
            System.Diagnostics.Debug.WriteLine(
              $"IsStrict: {kg_dm.GetIsStrict()}");
            System.Diagnostics.Debug.WriteLine(
              $"OIDPropertyName: {kg_dm.GetOIDPropertyName()}");
            System.Diagnostics.Debug.WriteLine(
              $"IsArcGISManaged: {kg_dm.GetIsArcGISManaged()}");
          }
        }
      });
    }
    Requirements

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

    ArcGIS Pro version: 3.2 or higher.
    See Also