【发布时间】:2013-11-14 18:34:04
【问题描述】:
我的应用程序从 SharePoint Web 服务获取数据(使用 SOAP 和 CAML 查询),我使用 Xdocument 文档来存储检索到的 xmlNode,然后将 xdocument 分配给 XMLDataSource,该 XMLDataSource 被绑定到 gridView。
现在我需要在绑定之前过滤 Xdocument,只选择元素 (ows_Partner_x0020_Type) 与变量匹配的那些记录。
我正在尝试这样:
doc = doc.Descendants(z + "row").Where(rows => rows.Attribute("ows_Partner_x0020_Type").Value == Partner_Type.SelectedValue);
或
var bar = doc.Descendants(z + "row").Where(rows => rows.Attribute("ows_Partner_x0020_Type").Value == Partner_Type.SelectedValue);
但问题是上述LINQ的返回类型是System.Collections.Generic.IEnumerable<System.Xml.Linq.XElement>
它与 XDocument 完全不同,它是作为 doc.ToString() 绑定到 XMLDataSource 所需的格式。
希望我能够解释这个问题。
非常感谢。
维沙尔
【问题讨论】:
标签: c# asp.net linq lambda linq-to-xml