Deleting relationships
In this section, we will be deleting one of the relationships we created. For this, we must create a new method for deleting a relationship. Add the following code to the DigitalTwinsManager
class:
public void DeleteRelationship(string twinSourceId, string twinDestinationId) { string relationShipId = RelationshipId(twinSourceId, twinDestinationId); try { client.DeleteRelationship(twinSourceId, relationShipId); } catch (RequestFailedException) { } }
Replace the code in the Program.Main
method in the Program.cs
file with the following code:
DigitalTwinsManager dtHelper = new DigitalTwinsManager(); dtHelper.DeleteRelationship("MainBuilding", "GroundFloor");
Run the application in Visual Studio. Open Azure Digital Twins...