我已经成功地让 MSFT Dynamic Linq 的东西工作了,但现在我需要创建一个包含属性的“Where”子句。
我得到的错误是“不存在适用的聚合方法'First'”
这是我的代码:
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);
这是我的 XML
<vocabulary>
<vocabularyheader>
<vocabularyid>5</vocabularyid>
<vocabularyname>Scheduled Procedure</vocabularyname>
</vocabularyheader>
<vocabularybody>
<procedure code="28002" type="Surgery"/>
</vocabularybody>
</gazoontvocabulary>