开发者

Question about Linq to xml from a tutorial I am following

I am following this tutorial

var groups = from sharePo开发者_如何学运维intGroup 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

                };

They have this: groupsXml.Root.Elements("Group") but when I try to do this I get an error

Error 3 Could not find an implementation of the query pattern for source type 'System.Collections.Generic.IEnumerable'. 'Select' not found. Are you missing a reference to 'System.Core.dll' or a using directive for 'System.Linq'

When I look at my references I can't see System.Linq(only System.Xml.Linq; and SharePoint.linq)

When I look up on msdn I see that it takes in a "Xname" instead of a string


  1. Xname has a constructor that takes a string, so this is correct.
  2. If you have no using System.Linq;, you need to add it.
  3. You don't need to add any reference to your project. The namespace System.Linq is defined in the System.Core.dll assembly, which is referenced by default.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜