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

In This Topic
    GetDomains Method (KnowledgeGraph)
    In This Topic
    Gets all the ArcGIS.Core.Data.Domain in this knowledge graph. 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.
    No valid knowledge graph has been opened prior to invoking this operation.
    A geodatabase-related exception has occurred.
    Example
    Delete Domain on KG Schemas with SchemaBuilder
    await QueuedTask.Run(() =>
    {
      using (var kg = GetKnowledgeGraph())
      {
        if (kg == null)
          return;
    
        //Get all the domains in the KG
        var domains = kg.GetDomains();
        var sb = new SchemaBuilder(kg);
    
        foreach (var domain in domains)
        {
          //skip the special provenance domain
          var name = domain.GetName();
          if (string.Compare(name, "esri__provenanceSourceType", true) == 0)
            continue;//skip this one
    
          //Delete all other domains
          if (domain is RangeDomain rd)
            sb.Delete(new RangeDomainDescription(rd));
          else if (domain is CodedValueDomain cvd)
            sb.Delete(new CodedValueDomainDescription(cvd));
        }
    
        try
        {
          //note: will throw an InvalidOperationException if there are no operations
          //to run. Will also delete associated fields dependent on deleted domain(s)
          if (!kg.ApplySchemaEdits(sb))
          {
            var err_msg = string.Join(",", sb.ErrorMessages.ToArray());
            System.Diagnostics.Debug.WriteLine($"Delete domains error: {err_msg}");
          }
        }
        catch (Exception ex)
        {
          System.Diagnostics.Debug.WriteLine(ex.ToString());
        }
      }
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.4 or higher.
    See Also