Quantcast
Channel: ActiveTopics
Viewing all articles
Browse latest Browse all 72689

check if Node is included in DynamicNodeList

$
0
0

I have a very simple issue (it seems) - Id like to get distinct parent nodes from a DynamicNodeList.

I have no trouble creating a new DynamicNodeList with the parent nodes, but want to get rid of the duplicates. Distinct on Items throws no errors, but I suspect that dynamic nodes are all distinct.

So the solution seems to be only to add items that doesn't already exists in the DynamicNodeList:

@{
      DynamicNodeList uniqueList = new DynamicNodeList();
    }
    <ul>
    @foreach (DynamicNode item in followedNodes) {  
      if (uniqueList.Items.Where("Id == item.Id").Count() 1) {
        uniqueList.Add(item.Parent);     
      }
    }
 
    @foreach (DynamicNode item in uniqueList.Items.Distinct()) {
      <li>
        <href="@item.Url">@item.Name</a
      </li>
    }
    </ul>  

The above seems clumsy and throws an error with Where:'System.Collections.Generic.List' does not contain a definition for 'Where' and the best extension method overload 'System.Linq.Enumerable.Where(System.Collections.Generic.IEnumerable, System.Func)' has some invalid arguments

Any ideas?

 


Viewing all articles
Browse latest Browse all 72689

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>