ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.KnowledgeGraph Namespace / KnowledgeGraphInvestigation Class / AddQueryDefinition Method
The ArcGIS.Core.CIM.CIMKnowledgeGraphQueryDefinition to add to the investigation.
Example

In This Topic
    AddQueryDefinition Method
    In This Topic
    Adds a ArcGIS.Core.CIM.CIMKnowledgeGraphQueryDefinition to this investigation. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Sub AddQueryDefinition( _
       ByVal queryDefinition As CIMKnowledgeGraphQueryDefinition _
    ) 
    public void AddQueryDefinition( 
       CIMKnowledgeGraphQueryDefinition queryDefinition
    )

    Parameters

    queryDefinition
    The ArcGIS.Core.CIM.CIMKnowledgeGraphQueryDefinition to add to the investigation.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    The queryDefinition is null or the name of the queryDefinition is null or empty.
    The queryDefinition cannot be added to the investigation.
    Remarks
    Query definition names must be unique within an investigation. If the name of the query definition to be added already exists in the investigation, then a numerical suffix is applied to the query definition name to ensure it is unique. This check is case sensitive.
    Example
    Add Query Definition
    {
      var newQueryDefinition = new CIMKnowledgeGraphQueryDefinition();
      newQueryDefinition.Name = "Query1";
      newQueryDefinition.ProvenanceBehavior = ProvenanceBehavior.Include;
      newQueryDefinition.OpenCypherQuery = "MATCH (n) RETURN n LIMIT 10\"";     // return the first 10 entities
    
      // access the currently active knowledge graph investigation view
      KnowledgeGraphInvestigationView activeView = KnowledgeGraphInvestigationView.Active;
      KnowledgeGraphInvestigation investigation = activeView?.Investigation;
      if (investigation != null)
      {
        await QueuedTask.Run(() =>
        {
          // add the new query defintiion
          investigation.AddQueryDefinition(newQueryDefinition);
        });
      }
    }
    Requirements

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

    ArcGIS Pro version: 3.7 or higher.
    See Also