ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Editing Namespace / KnowledgeGraphRelationshipDescription Class / KnowledgeGraphRelationshipDescription Constructor / KnowledgeGraphRelationshipDescription Constructor(Guid,Guid,IReadOnlyDictionary<String,Object>)
The globalID of the row in the origin table.
The globalID of the row in the destination table.
(Optional) The attributes to assign the new row in the relationship table.
Example

In This Topic
    KnowledgeGraphRelationshipDescription Constructor(Guid,Guid,IReadOnlyDictionary<String,Object>)
    In This Topic
    Creates a new instance of the KnowledgeGraphRelationshipDescription class.
    Syntax
    Public Function New( _
       ByVal origin As Guid, _
       ByVal destination As Guid, _
       Optional ByVal attributes As IReadOnlyDictionary(Of String,Object) _
    )
    public KnowledgeGraphRelationshipDescription( 
       Guid origin,
       Guid destination,
       IReadOnlyDictionary<string,object> attributes
    )

    Parameters

    origin
    The globalID of the row in the origin table.
    destination
    The globalID of the row in the destination table.
    attributes
    (Optional) The attributes to assign the new row in the relationship table.
    Example
    Create a new Relationship from Existing Entities 2
    {
      var create_rel2 = await QueuedTask.Run(() =>
      {
        //Instantiate an operation for the Create
        var edit_op = new EditOperation()
        {
          Name = "Create a new relationship record",
          SelectNewFeatures = true
        };
    
        //Use datasets or feature layer(s) or standalone table(s)
        //Get a reference to the KnowledgeGraph
        //var kg = ... ; 
    
        //We will use a relate called 'HasEmployee' to relate an Organization w/ a Person
        //Use either tables or map members to get the rows to be related...
        var org_fc = kg.OpenDataset<FeatureClass>("Organization");
        var person_tbl = kg.OpenDataset<Table>("Person");
    
        //Get the relationship dataset
        //We can use either a table or standalone table
        var emp_tbl = kg.OpenDataset<Table>("HasEmployee");
    
        // get the origin, destination records
        Guid guidOrigin = Guid.Empty;
        Guid guidDestination = Guid.Empty;
        using (var rc = org_fc.Search())
        {
          if (rc.MoveNext())
            //Use the KnowledgeGraphPropertyInfo to avoid hardcoding...
            guidOrigin = rc.Current.GetGlobalID();
        }
        using (var rc = person_tbl.Search())
        {
          if (rc.MoveNext())
            //Use the KnowledgeGraphPropertyInfo to avoid hardcoding...
            guidDestination = rc.Current.GetGlobalID();
        }
    
        //Add any extra attribute information for the relation as needed
        var attribs = new Dictionary<string, object>();
        attribs["StartDate"] = new DateTimeOffset(DateTime.Now);
    
        var rd = new KnowledgeGraphRelationshipDescription(guidOrigin, guidDestination, attribs);
        //Add a create for the relationship to the operation
        edit_op.Create(emp_tbl, rd);
    
        //Do the create
        return edit_op.Execute();
      });
    }
    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