ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / KnowledgeGraphLayerCreationParams Class / IDSet Property
Example

In This Topic
    IDSet Property
    In This Topic
    Limits the content of the KnowledgeGraph composite layer to the Named Object types and associated records in the IDSet.
    Syntax
    public KnowledgeGraphLayerIDSet IDSet {get; set;}
    Public Property IDSet As KnowledgeGraphLayerIDSet
    Remarks
    The KnowledgeGraph layer created in a Map contains sub feature layers or sub standalone tables for each Named Object type in the ID set. To set the output content of the KnowledgeGraph composite layer, add an entry to the ID set for each Named Object type to be included in the output along with a list of their relevant record ids. Specify a null or empty list for a given entry to include all records for that particular type.
    Note: Named Object names in a ID set entry are case-sensitive.
    If there are Named Object type names specified in the ID set that do not match a Named Object type name in the KnowledgeGraph then a KnowledgeGraphLayerException will be thrown when the layer is created. The exception will contain the list of invalid Named Object types.

    If you specify a null or empty IDSet, then a KnowledgeGraphLayerExeption will be thrown. A KnowledgeGraph composite layer with no sub layers and sub tables cannot be created.

    See KnowledgeGraphLayerIDSet
    Example
    Create a KG Layer containing a subset of Entity and Relate types
    QueuedTask.Run(() =>
    {
      //To create a KG layer (on a map or link chart) with a subset of
      //entities and relates, you must create an "id set". The workflow
      //is very similar to how you would create a SelectionSet.
    
      //First, create a dictionary containing the names of the types to be
      //added plus a corresponding list of ids (just like with a selection set).
      //Note: null or an empty list means add all records for "that" type..
      var kg_datamodel = kg.GetDataModel();
      //Arbitrarily get the name of the first entity and relate type
      var first_entity = kg_datamodel.GetEntityTypes().Keys.First();
      var first_relate = kg_datamodel.GetRelationshipTypes().Keys.First();
    
      //Make entries in the dictionary for each
      var dict = new Dictionary<string, List<long>>();
      dict.Add(first_entity, new List<long>());//Empty list means all records
      dict.Add(first_relate, null);//null list means all records
      //or specific records - however the ids are obtained
      //dict.Add(entity_or_relate_name, new List<long>() { 1, 5, 18, 36, 78});
    
      //Create the id set...
      var idSet = KnowledgeGraphLayerIDSet.FromDictionary(kg, dict);
    
      //Create the layer params and assign the id set
      var kg_params = new KnowledgeGraphLayerCreationParams(kg)
      {
        Name = "KG_With_ID_Set",
        IsVisible = false,
        IDSet = idSet
      };
    
      //Call layer factory with map or group layer container
      //A KG layer containing just the feature layer(s) and/or standalone table(s)
      //for the entity and/or relate types + associated records will be created
      var kg_layer = LayerFactory.Instance.CreateLayer<KnowledgeGraphLayer>(
          kg_params, map);
    
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.3 or higher.
    See Also