I’m using Scott Gu’s dynamic linq library for Linq to XMl. The problem is I don’t know how to refer an element itself value inside of the dynamic query.
What I want to do is as follows:
var doc = XDocument.Load("test.xml");
var ret = doc.Descendants("Row").Where(x => x.Element("ID").Value == "2").ToList();
I want to replace the where clause to dynamic linq, but I don’t know how I should rewrite it. I tried as follows:
var ret = doc.Descendants("Row").Where("Element(""ID"").Value == @0", "2").ToList();
But it gives me an error saying “There is no property named Element” or something.
Could anyone please tell me how to do that?
Thanks in advance,
Yoo
Okay, I did a trick. It’s not great but works. It might cause a performance problem, but for now, it’s okay.
If you have a better solution, please post it here.
Thanks,
Yoo