How can I get similar functionality for doc.Descendants () using linq to collection objects containing deep X-level struts of the same objects?
The last nested collection contains the data you need to retrieve, and all other parent collections are just groupings. I could convert the collection to XDocument and call the descendant function, but I would rather simulate this functionality against this collection of objects.
public class ProductLine
{
public string Id {get;set;}
public string ParentId {get;set;}
public string Name {get;set;}
public string Type {get;set;}
public string Level {get;set;}
public IEnumerable<ProductLine> Children {get;set;}
}
I can have a ProductLine list that contains child lists of ProductLine. Nested levels may vary depending on how the data was configured, so I never know how many levels exist. The bottommost list will have Type = "Model", while each previous list will have Type = "Series", which will lead to something like:
Series1
Series2
Series3
Model1
Model1
Series2
Model3
Model4
jason source
share