2011-06-30 104 views
1

我试图使用linq从XML文件中提取名称列表中MVC3工作。中的LINQ MVC抱怨缺少引用

List<String> firstNames = (from p in x.Descendants("Row") 
          orderby p.Element("id").Value 
          select p.Element("firstName").Value).ToList(); 

编译器不断抱怨:

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

我检查和System.Core是在引用文件夹并没有在文件中using System.Linq;声明。

任何人都知道为什么发生这种情况?

回答

1

添加到您的代码

using System.Xml.Linq; 
相关问题