Hooked on LINQ

Hooked on LINQ - Developers' Wiki
for .NET Language Integrated Query

Quick Search

Advanced Search »

LINQ to Objects FAQ

Modified: 2008/07/10 16:59 by drewnoakes - Categorized as: General, LINQ to Objects
Edit

Q. What is LINQ?

LINQ is a set of language features introduced in .NET 3.5 (shipping Visual Studio 2008) that allow you to write queries similar to SQL like statements in Visual Basic or C# programs (other language support is available, but these are the main ones). LINQ knows the data-source you are trying to query (SQL Server, object collection, or another source) and executes the query expression returning the result in the form you ask.

Edit

Q. What is LINQ to Objects?

LINQ to Objects is a specific LINQ implementation for any collection type that implements the IEnumerable interface (most, if not all collections in .NET). LINQ to Objects introduces a set of standard query operators like Where, Select, Sum, Count, etc. See: LINQ to Objects main page, and LINQ to Objects 5 minute overview.

Edit

Q. How do I enable LINQ in my code?

To use LINQ to Objects in Visual Studio 2008 -

1) add a reference to the System.Core.dll (if it is grayed out, go to your project properties and set the target framework to .NET 3.5)
2) add the following using statement at the top of your class file: using System.Linq;


Edit

Q. Why don't I see any "Where" method on my List instance?

Check that -

1) You are running Visual Studio 2008
2) Your project has a reference to the System.Core.dll assembly
3) Your class file has the following using statement at the top of your class file: using System.Linq;


Edit

Q. What versions of C# Supports LINQ?

C#3.0 that ships in the .NET 3.5 framework as part of Visual Studio 2008 supports LINQ. It was possible to run a LINQ preview in Visual Studio 2005 mid 2006, but as the beta releases of Visual Studio 2008 became available this support was dropped.

Edit

Q. Can I write my own operators?

Yes. See Writing Operators for examples.

Edit

Q. Do I need to know LINQ syntax to program?

No. Developing using LINQ is completely optional. LINQ does remove a lot of complexity in code that enumerated over object collections. It is definately worth learning how to writing queries and understand the Standard Query Operators that ship out-of-the-box.

Edit

Q. What .NET languages currently support LINQ?

Currently C# and Visual Basic shipping with the .NET Framework 3.5 (in Visual Studio 2008) have specific language features and debugger support for LINQ.

If you would like to comment on this page, click on the Discuss button located on the top-right of each page. Feel free to edit any mistakes or ommissions you find. If you have an objection or find in-appropriate content then contact the administrator. This website is not affiliated with Microsoft®, all content and opinions are those of the specific author and some advice, solutions and article may contain un-intentional errors - please use care. Powered by ScrewTurn Wiki version 2.0.33. Some of the icons created by FamFamFam.