Imports and references required to use LINQ

28,176

Update: based on the comments targeting .NET 2.0 and attempting to use System.Linq would result in a compiler error as follows:

Namespace or type specified in the Imports 'System.Linq' doesn't contain any public member or cannot be found.

To change the targeted framework version go to the project's Properties -> Compile -> Advanced Compile Options... set the Target Framework to ".NET Framework 3.5" and recompile.

In case using .NET 3.5 is not feasible then you can use LINQBridge to make use of LINQ to Objects while targeting the .NET 2.0 framework.

Share:
28,176
JosephStyons
Author by

JosephStyons

I started out as a professional developer using Delphi and Oracle in a Win32 client-server environment for a manufacturing company. I worked for five years in consulting, implementing solutions for dozens of clients and using many disparate technologies. Since then, I've worked for and with the non-profit industry, building applications that help them move their missions forward. My bread-and-butter is VB.NET and C# against a SQL Server back-end using a SOA architecture. But I can and will use whatever tool gets the job done, and I've had fun doing so with Angular, jQuery, ASP.NET, PHP, and even my own homemade frameworks to deliver solutions against that platform.

Updated on July 13, 2020

Comments

  • JosephStyons
    JosephStyons almost 4 years

    I have never used LINQ before, and I am getting an error in an application that does use it. This is a VB.NET (.NET 2.0) project in Visual Studio 2008.

    Here is the offending code:

    Dim orderedRows = From r In resultRows Order By r.FIELDNAME Select r
    

    And here is the error (names changed to something generic, but otherwise accurate):

    Expression of type '1-dimensional array of 
    Company.OurLibrary.FunctionalArea.Library.StoredProcStuff.USP_MYPROC.ResultRow'
    is not queryable. Make sure you are not missing an assembly
    reference and/or namespace import for the LINQ provider.
    C:\project\filename.vb
    

    So I recognize that I need to import LINQ libraries. This link led me to add "Imports System.Linq" to the file, but that is an unresolved reference. Based on the same link, I figured I needed to add a reference to "System.Core" to my project, but it is not listed as an available option when I try to add a reference (nor is it already checked).

    I feel sure I'm missing something basic. Can someone point me in the right direction?

    TL;DR: What do I need for LINQ to work?