ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data.Knowledge Namespace / KnowledgeGraph Class
Members Example

In This Topic
    KnowledgeGraph Class
    In This Topic
    Represents a Knowledge Graph datastore.
    Object Model
    KnowledgeGraph ClassConnector ClassKnowledgeGraphDataModel ClassDatastoreProperties ClassKnowledgeGraphPropertyInfo ClassSpatialReference ClassSQLSyntax ClassKnowledgeGraphCursor ClassKnowledgeGraphCursor Class
    Syntax
    public sealed class KnowledgeGraph : ArcGIS.Core.Data.Datastore, System.IDisposable  
    Public NotInheritable Class KnowledgeGraph 
       Inherits ArcGIS.Core.Data.Datastore
       Implements System.IDisposable 
    Example
    Opening a Connection to a KnowledgeGraph
    string url =
      @"https://acme.server.com/server/rest/services/Hosted/AcmeKnowledgeGraph/KnowledgeGraphServer";
    
    QueuedTask.Run(() =>
    {
      //Create a connection properties
      var kg_props =
          new KnowledgeGraphConnectionProperties(new Uri(url));
      try
      {
        //Open a connection
        using (var kg = new KnowledgeGraph(kg_props))
        {
          //TODO...use the KnowledgeGraph
        }
      }
      catch (GeodatabaseNotFoundOrOpenedException ex)
      {
        System.Diagnostics.Debug.WriteLine(ex.ToString());
      }
    });
    
    Getting a Connection from a KnowledgeGraphLayer
    var kgLayer = MapView.Active.Map.GetLayersAsFlattenedList()
            .OfType<KnowledgeGraphLayer>().FirstOrDefault();
    
    
    QueuedTask.Run(() =>
    {
      // use the layer directly
      KnowledgeGraph datastore = kgLayer.GetDatastore();
      
      // or you can use any of the sub items since
      //KnowledgeGraphLayer is a composite layer - get the first 
      // child feature layer or standalone table
      var featlayer = kgLayer?.GetLayersAsFlattenedList()?
                      .OfType<FeatureLayer>()?.FirstOrDefault();
      KnowledgeGraph kg = null;
      if (featlayer != null)
      {
        using (var fc = featlayer.GetFeatureClass())
          kg = fc.GetDatastore() as KnowledgeGraph;
        //TODO use KnowledgeGraph
      }
      else
      {
        //try standalone table
        var stbl = kgLayer?.GetStandaloneTablesAsFlattenedList()?
                        .FirstOrDefault();
        if (stbl != null)
        {
          using (var tbl = stbl.GetTable())
            kg = tbl.GetDatastore() as KnowledgeGraph;
          //TODO use KnowledgeGraph
        }
      }
    });
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.CoreObjectsBase
          ArcGIS.Core.Data.Datastore
             ArcGIS.Core.Data.Knowledge.KnowledgeGraph

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.2 or higher.
    See Also