1

我已经成功地让 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>

4

1 回答 1

1

我还不熟悉动态 LINQ 库,但是对于 where 子句,您不应该需要相等运算符 (==) 而不是赋值运算符 (=) 吗?

于 2009-02-08T05:56:52.570 回答