ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Editing Namespace / EditOperation Class / Delete Method / Delete(Table,KnowledgeGraphRelationshipDescription) Method
The relationship table representing an association between two entities in a knowledge graph.
A description of the relationship to delete.
Example

In This Topic
    Delete(Table,KnowledgeGraphRelationshipDescription) Method
    In This Topic
    Deletes a relationship between the two specified entities in the KnowledgeGraphRelationshipDescription.
    Syntax

    Parameters

    relationshipTable
    The relationship table representing an association between two entities in a knowledge graph.
    relationshipDescription
    A description of the relationship to delete.
    Exceptions
    ExceptionDescription
    relationshipTable cannot be null.
    relationshipDescription cannot be null.
    The relationshipTable is either not part of a Knowledge Graph or not a Knowledge Graph relate type.
    Remarks
    The Delete method removes a relationship between the origin entity and the destination entity specified in the RelationshipDescription.
    Example
    Delete a Relationship record 2
    {
      var mv = MapView.Active;
      await QueuedTask.Run(() =>
      {
    
        var edit_op = new EditOperation()
        {
          Name = "Delete a Relationship record"
        };
    
        //We are  going to use mapmembers in this example
        //we could equally use feature classes/tables
        var kg_layer = mv.Map.GetLayersAsFlattenedList()?
                      .OfType<ArcGIS.Desktop.Mapping.KnowledgeGraphLayer>().First();
    
        //entities
        var entityOrg = kg_layer.GetStandaloneTablesAsFlattenedList()
                        .First(child_layer => child_layer.Name == "Organization");
        var entityPerson = kg_layer.GetStandaloneTablesAsFlattenedList()
                        .First(child_layer => child_layer.Name == "Person");
    
        //Relationship
        var rel_stbl = kg_layer.GetStandaloneTablesAsFlattenedList()
                        .First(child_layer => child_layer.Name == "HasEmployee");
    
        // get the origin, destination records
        Guid guidOrigin = Guid.Empty;
        Guid guidDestination = Guid.Empty;
        using (var rc = entityOrg.Search())
        {
          if (rc.MoveNext())
            //Use the KnowledgeGraphPropertyInfo to avoid hardcoding...
            guidOrigin = rc.Current.GetGlobalID();
        }
        using (var rc = entityPerson.Search())
        {
          if (rc.MoveNext())
            //Use the KnowledgeGraphPropertyInfo to avoid hardcoding...
            guidDestination = rc.Current.GetGlobalID();
        }
    
        var rd = new KnowledgeGraphRelationshipDescription(guidOrigin, guidDestination);
        edit_op.Delete(rel_stbl, rd);
        edit_op.Execute();//Do the delete
      });
    }
    Requirements

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

    ArcGIS Pro version: 3.4 or higher.
    See Also