Roshan Srivastava
Roshan Srivastava

Reputation: 476

Querying a collection of collection using Linq

I have a nested collection of collection of array that can go to any level I have to query based on a particular id and get the details of that array.

Upvotes: 2

Views: 112

Answers (1)

Magnus
Magnus

Reputation: 46909

Sounds like you need a recursive function. I wrote an extension method to IEnumerable called SelectRecursive on codeproject a while ago: http://www.codeproject.com/Tips/80746/Select-Recursive-Extension-method

Usage: var allChildren = node.ChildNodes.SelectRecursive(n => n.ChildNodes);

Upvotes: 3

Related Questions