【发布时间】:2011-04-06 17:30:30
【问题描述】:
我关注 this tutorial
var groups = from sharePointGroup in groupsXml.Root.Elements("Group")
select new
{
Name = sharePointGroup.Attribute("Name").Value,
Owner = sharePointGroup.Attributes("Owner").Any() ? sharePointGroup.Attribute("Owner").Value : null,
Description = sharePointGroup.Attributes("Description").Any() ? sharePointGroup.Attribute("Description").Value : string.Empty,
PermissionLevel = sharePointGroup.Attributes("PermissionLevel").Any() ? sharePointGroup.Attribute("PermissionLevel").Value : null,
Users = sharePointGroup.Elements("User").Any() ? sharePointGroup.Elements("User") : null
};
他们有这个:groupsXml.Root.Elements("Group") 但是当我尝试这样做时,我得到一个错误
错误 3 找不到 查询模式的实现 对于源类型 'System.Collections.Generic.IEnumerable'。 未找到“选择”。你错过了一个 引用“System.Core.dll”或 使用“System.Linq”指令
当我查看我的参考资料时,我看不到 System.Linq(仅 System.Xml.Linq;和 SharePoint.linq)
当我查看 msdn 时,我发现它接受的是“Xname”而不是字符串
【问题讨论】:
-
在 System.Linq 的类文件的顶部有 using 语句吗?使用 System.Linq;
标签: xml linq sharepoint sharepoint-2010 linq-to-xml