RowHandle Constructor(RowToken)
Creates a new instance of the RowHandle class, created from a
RowToken.
Public Function New( _
ByVal As RowToken _
)
Parameters
- token
- The RowToken used to create this RowHandle.
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();
});
Create utility network features and associations in a single edit operation
// Create an EditOperation
EditOperation editOperation = new EditOperation();
editOperation.Name = "Create pole; create transformer bank; attach transformer bank to pole";
// Create the transformer bank
RowToken transformerBankToken = editOperation.Create(transformerBankLayer, transformerBankAttributes);
// Create a pole
RowToken poleToken = editOperation.Create(poleLayer, poleAttributes);
// Create a structural attachment association between the pole and the transformer bank
RowHandle poleHandle = new RowHandle(poleToken);
RowHandle transformerBankHandle = new RowHandle(transformerBankToken);
AssociationDescription poleAttachment = new AssociationDescription(AssociationType.Attachment, poleHandle, transformerBankHandle);
editOperation.Create(poleAttachment);
// Execute the EditOperation
editOperation.Execute();
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.