I have had some success getting the MSFT Dynamic Linq stuff to work, but now I need to create a "Where" clause that includes an Attribute.
The error I get is "No applicable aggregate method 'First' exists"
Here is my code:
where = "Element(XName.Get(\"procedure\")).Attributes(XName.Get(\"code\")).First() = \"28002\""; var q2 = doc.Elements().Descendants("vocabularybody").AsQueryable().Where(where); if (q2 != null && q2.Count() > 0) foundItems.Add(item);
here is my XML
<vocabulary> <vocabularyheader> <vocabularyid>5</vocabularyid> <vocabularyname>Scheduled Procedure</vocabularyname> </vocabularyheader> <vocabularybody> <procedure code="28002" type="Surgery"/> </vocabularybody> </gazoontvocabulary>
I'm not familiar with the Dynamic LINQ library yet but shouldn't you need the equality operator (==) and not the assignment operator (=) for the where clause?