Hooked on LINQ

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

Quick Search

Advanced Search »

LINQ to Objects

Modified: 2007/04/10 18:52 by t_magennis - Categorized as: LINQ to Objects

Table of Contents [Hide/Show]


Edit

Overview

LINQ to Objects allows .NET developers to write “queries” over collections of objects. Out of the box there is a large set of query operators that provide a similar depth of functionality to what we expect from any SQL language working with a relational database, and if what we need isn’t present out-of-the-box, we can add our own.

Traditionally, working with collections of objects meant writing a lot of looping code using for loops or foreach loops to iterate through a list carrying out filtering using if statements, and some action like keeping a running sum of a total property. LINQ frees you from having to write looping code; it allows you to write queries that filter a list or calculate aggregate functions on elements in a collection as a set.

We can write queries against any collection type that implements an interface called IEnumerable (and also a new interface called IQueryable, but more on that later). This is almost any collection type built into the .NET class libraries including simple arrays like string[], or int[], and any List<T> collection we define.

Features at a glance:

  • Query language over collections of objects
  • Standard SQL like set of query operators, including joins and grouping
  • New query operators can be added, fully extensible
  • Intellisense and compiler syntax checking support in Visual Studio

LINQ to Objects - 5 minute overview

Edit

Standard Query Operators

The backbone of LINQ to Objects is the Standard Query Operators that provide query operators similar to those found in a SQL like language. You can also Write you own operators, pretty easily if one of these doesn't suit your needs.


LINQ 101 Samples - This Microsoft link is to the source-code for 100 sample snippets showing how to use the Standard Query Operators.

Edit

Resources

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.