【问题标题】:first issue with first linq第一个 linq 的第一个问题
【发布时间】:2012-10-26 14:02:14
【问题描述】:

我正在使用 vs2008 框架 3.5,我第一次关注 linq,遵循这些 http://msdn.microsoft.com/it-it/library/bb385164(v=vs.90).aspx

像这样创建数据源http://msdn.microsoft.com/it-it/library/bb385204(VS.90).aspx

但我无法导入/使用 linq。制作 consoleApplication System.Core.dll 引用和导入 System.Linq 应该是自动的吧?!

写在main中:

Dim students = GetStudents()
'Dim students As List(Of Student) = GetStudents() 'the same thing with this one
Dim studentQuery = From currentStudent In students _
                   Where currentStudent.Rank <= 10 _
                   Select currejt

IDE 不喜欢查询中的学生并说:

Error   1   Expression of type 'System.Collections.Generic.IEnumerable(Of ConsoleApplication1.Module1.Student)' 
is not queryable. Make sure you are not missing an assembly reference and/or namespace 
import for the LINQ provider. ConsoleApplication1 

我哪里错了!?

如果我尝试“导入 System.Linq”,它会显示

警告 1 在 Imports 'System.Linq' 中指定的命名空间或类型 不包含任何公共成员或找不到。确保 命名空间或类型已定义并包含至少一个公共 成员。确保导入的元素名称不使用任何别名。

【问题讨论】:

  • 你有对 System.Core 的引用吗?

标签: .net vb.net linq visual-studio-2008 .net-3.5


【解决方案1】:

引用和导入是不同的 - 您必须从您的项目(System.Core,System.Linq 命名空间所在的位置)引用该 dll 才能将其导入您的类...

右键单击项目/引用,选择添加引用,转到选项卡“.NET”并选择 System.Core。

【讨论】:

  • 谢谢这是问题所在...我无法添加该 dll,因为现在项目设置在框架目标 2.0 上,我可以在哪里将其更改为 3.5?再次感谢
  • 解决了!对于任何有同样问题的人:VB项目项目属性->编译->高级编译选项谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2010-10-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多