collecting data from IEnumerable.Descendants

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Ive got code that looks like
<pre class="prettyprint IEnumerable<XElement> controlnode = (from controlnodes in report.Descendants(Globals.xnControl)
where (controlnodes.Attribute(Globals.xnControl).Value == control)
select controlnodes);
IEnumerable<XElement> sources = (from finding in controlnode.Descendants(Globals.xnFinding)
where (finding.Attribute(Globals.xnToolIDNode).Value == toolid)
select finding.Element(Globals.xnSourcesNode));
IEnumerable<XElement> lrus = (from sourcesnode in sources
where sourcesnode.Attribute(Globals.xnSite).Value == site.ToString()
select sources.Descendants(Globals.xnFinding)); [/code]
but the last IEnumerable<XElement> lrus is throwing a casting error. Ive got two questions.
How do I fix this casting error?
Im assuming that these multiple sequential linq lines would be more optimal written as one linq line. How would I do that?

Thanks, youve all been great with the support.

View the full article
 
Back
Top