当前位置:编程学习 > C#/ASP.NET >>

Expression of type 'Object' is not queryable. Make sure you are not missing an a

  下面的代码红色部分报错:
 Expression of type 'Object' is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider

已经引入了
Imports System.Linq
Imports System.Data.Linq
 
Dim db As RAWSDataClassesDataContext = New RAWSDataClassesDataContext()
        
        Dim q = From item In db.TaskMasters
                Where item.taskId = 2
                Select item

       
        Dim q1 = From item In q
          Where item.Leid = 21
        Select item

 网上查不到方案。 linq .net linq to sql issue --------------------编程问答--------------------
Dim q  As IQueryable(Of TaskMaster) = From item In db.TaskMasters.AsQueryable()
                Where item.taskId = 2
                Select item


 you must also turn Option Infer on (in Visual Basic only) --------------------编程问答--------------------
引用 1 楼 q107770540 的回复:
Visual Basic code?123Dim q  As IQueryable(Of TaskMaster) = From item In db.TaskMasters.AsQueryable()                Where item.taskId = 2                Select item

 you must also turn……


It works. Thank you :)

But I encountered a strange thing: the same code(my original code) works well in another project which I created to test this issue, and  it doesn't work in my current project.

@q107770540, Do you know why?
补充:.NET技术 ,  LINQ
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,