ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Editing Namespace / KnowledgeGraphRelationshipDescription Class / KnowledgeGraphRelationshipDescription Constructor / KnowledgeGraphRelationshipDescription Constructor(RowHandle,RowHandle,IReadOnlyDictionary<String,Object>)
The RowHandle of the row in the origin table.
The RowHandle 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(RowHandle,RowHandle,IReadOnlyDictionary<String,Object>)
    In This Topic
    Creates a new instance of the KnowledgeGraphRelationshipDescription class.
    Syntax
    public KnowledgeGraphRelationshipDescription( 
       RowHandle origin,
       RowHandle destination,
       IReadOnlyDictionary<string,object> attributes
    )
    Public Function New( _
       ByVal origin As RowHandle, _
       ByVal destination As RowHandle, _
       Optional ByVal attributes As IReadOnlyDictionary(Of String,Object) _
    )

    Parameters

    origin
    The RowHandle of the row in the origin table.
    destination
    The RowHandle 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 and New Entities 2
    var createRel = await QueuedTask.Run(() =>
    {
      //This example uses a KnowledgeGraphRelationshipDescription
      var edit_op = new EditOperation()
      {
        Name = "Create entities and a relationship using a KG relate desc",
        SelectNewFeatures = true
      };
    
      //We are just 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();
      //From the KG Layer get the relevant child feature layer(s) and/or standalone
      //table(s)
      var org_fl = kg_layer.GetLayersAsFlattenedList().OfType<FeatureLayer>()
                      .First(child_layer => child_layer.Name == "Organization");
    
      var person_stbl = kg_layer.GetStandaloneTablesAsFlattenedList()
                      .First(child_layer => child_layer.Name == "Person");
    
      var rel_stbl = kg_layer.GetStandaloneTablesAsFlattenedList()
                      .First(child_layer => child_layer.Name == "HasEmployee");
    
      var attribs = new Dictionary<string, object>();
    
      //New Organization
      attribs["Name"] = "Acme Ltd.";
      attribs["Description"] = "Specializes in household items";
      attribs["SHAPE"] = org_location;
    
      //Add it to the operation - we need the rowtoken
      var rowtoken_org = edit_op.Create(org_fl, attribs);
    
      attribs.Clear();//we are going to re-use the dictionary
    
      //New Person
      attribs["Name"] = "Bob";
      attribs["Age"] = "41";
      attribs["Skills"] = "Plumbing, Framing, Flooring";
    
      //Add it to the operation
      var rowtoken_person = edit_op.Create(person_stbl, attribs);
    
      attribs.Clear();
    
      //Create the new relationship using a KnowledgeGraphRelationshipDescription
      //Row handles act as the placeholders for the TO BE created new entities that will
      //be related
      var src_row_handle = new RowHandle(rowtoken_org);
      var dest_row_handle = new RowHandle(rowtoken_person);
    
      //Add any extra attribute information for the relation as needed
      attribs["StartDate"] = new DateTimeOffset(DateTime.Now);
    
      var rel_desc = new KnowledgeGraphRelationshipDescription(
                                  src_row_handle, dest_row_handle, attribs);
    
      //Add the relate description to the edit operation
      edit_op.Create(rel_stbl, rel_desc);
    
      //Execute the create of the entities and relationship
      return edit_op.Execute();
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.4 or higher.
    See Also