Looping through nodes within the server

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
NicovanVeen
Hero Member
Hero Member
Posts: 23
Joined: 23 Aug 2013, 09:30

Looping through nodes within the server

Post by NicovanVeen »

Hi

I would like to know the best way of looping - or 'browsing' you might call it - through a collection of nodes within the server.
Suppose I have a server called "Footballteam" and I have a node of type "Player" with property "Name" and a node of type "Goal" with property "Scoredby". Futher on I have a (non-hierarical) reference called "PlayerHasscoredGoal".

Now I do the following:

Add 20 nodes of Players

Add 60 nodes of Goals

Then I want to do something like :

foreach Player in Footballteam
foreach Goal in Footballteam
if (Player.Name == Goal.Scoredby)
AddReference PlayerHasscoredGoal to Player that referes to Goal

What is the best way to do this? One solution I would think of is to make a flat list of objectnodes with Players and Goals at the point of adding the nodes to the server and put some information in the Userdata. Then looping the flat lists. Another way I can imagine is to browse the nodes in a ServerInternalClient and to add the references there. Both methods have their disadvantages. Is there a easier way ?

Kind regards

Nico

User avatar
Support Team
Hero Member
Hero Member
Posts: 3068
Joined: 18 Mar 2011, 15:09

Re: Looping through nodes within the server

Post by Support Team »

Hi Nico,

I assume you have loaded the nodes into memory with CreateObject/CreateVariable?
If this is the case the best approach would add the reference when you add the Goal object with a call to AddReference.
This approach would work if the Goals are added in method or callback function.

Best regards
Support Team

Post Reply