c# - Cannot implicitly convert type 'IEnumerable<XElement>' to 'bool' -


i want find xelement attribute.value children have concrete attribute.value.

string fathername =  xmlnx.descendants("assembly")                            .where(child => child.descendants("component")                                .where(name => name.attribute("name").value==item))                            .select(el => (string)el.attribute("name").value);  

how can attribute.value? bool?

edited have following xml:

<assembly name="1">   <assembly name="44" />   <assembly name="3">      <component name="2" />   </assembly>   </assembly> 

i need attribute.value children (xelement) has expecific attribute.value in example, string "3" because searching parent of child attribute.value == "2"

because of how nested where clauses written.

the inner clause reads

child.descendants("component").where(name => name.attribute("name").value==item) 

this expression has result of type ienumerable<xelement>, outer clause reads

.where(child => /* ienumerable<xelement> */) 

however where expects argument of type func<xelement, bool> , here end passing in func<xelement, ienumerable<xelement>> -- hence error.

i 'm not offering corrected version because intent not clear @ given code, please update question accordingly.

update:

looks want this:

xmlnx.descendants("assembly")      // filter assemblies down have matching component      .where(asm => asm.children("component")                      .any(c => c.name.attribute("name").value==item))      // select each matching assembly's name      .select(asm => (string)asm.attribute("name").value)      // , first result, or null if search unsuccessful      .firstordefault(); 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -