As per post Select element with given attribute using linq to xml what will be the equivalent lambda expression.
The below solution works fine
var artistsAndImage = from a in feed.Descendants("artist")
from img in a.Elements("image")
where img.Attribute("size").Value == "big"
select new { Name = a.Element("Name").Value
, Image = img.Value};
I tried the lambda expression but it’s not working 🙁
can somebody suggest the equivalent lambda expression.
Sure:
(Untested, but I think it should work.)
The tricky bit here is that the second
fromclause callsSelectManyand introduces a transparent identifier which I’ve made somewhat less transparent by calling itz.Any particular reason you want to avoid query expression syntax here though? It’s simpler in this example – I just use whichever is simpler for the query I’m writing.