This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Unfetch relationships?

Sebastian Uecker - Friday, July 4, 2014 4:33 AM:

Hi there,

so I wrote this method that receives an existing Item (parent) as a parameter, fetches a number of RelationshipTypes to it (names are taken from a string list) and then gets all Relationships on the parent to a variable via getRelationships() in order to further process them. 

My problem:

Before fetching the RelationshipTypes from the list, I want to strip off any "prefetched" relationships that may stick on the parent Item from before when it's passed to the method, hence just keeping the Item itself with its properties, id and type as a clean startoff. What would be the most effective way to achieve this since there is no unfetchRelationship-method defined for the IOM.Item?

Best regards

Sebastian



Sebastian Uecker - Friday, July 4, 2014 5:05 AM:

Alright, I guess I found a solution if anyone's interested:

 

XmlNode itemNode = parent.dom.FirstChild;

if (itemNode == null)

return null;

 

while (itemNode.Name != "Item")

{

itemNode = itemNode.FirstChild;

if (itemNode == null)

return null;

}

 

foreach (XmlNode node in itemNode.ChildNodes)

{

if(node.Name == "Relationships")

{

itemNode.RemoveChild(node);

break;

}

}