MVC 中的 Linq 抱怨缺少引用
我正在尝试使用 linq
在 MVC3
中从 XML 文件中提取名称列表。
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;
语句。
有谁知道为什么会发生这种情况?
I'm trying to work in MVC3
using linq
to extract a list of names from an XML file.
List<String> firstNames = (from p in x.Descendants("Row")
orderby p.Element("id").Value
select p.Element("firstName").Value).ToList();
The compiler keeps complaining:
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'
I've checked and the System.Core
is in the references folder and there is a using System.Linq;
statement in the file.
Anyone know why this is happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其添加到您的代码中
add this to your code