Chapter 23. Working with LINQ

Language INtegrated Query (LINQ, pronounced link) is potentially one of the best features that Microsoft has added to Visual Studio in a long time. It has the potential to change the way you write code and can help you create significantly faster code as well. The briefest way to describe LINQ is as a specialized query language that looks a little like Structured Query Language (SQL, pronounced sequel), yet works equally well on any data source for which you have a provider (the specialized code used to perform the LINQ query).

This short description really doesn't do LINQ justice. The "Sorting the Data Entries" section of Chapter 22 shows a use for LINQ that hardly falls into the usual category of a query. When you look at what the two lines of code in that example do, you begin to understand the vast scope of what LINQ can possibly do for you as a developer. This chapter builds your knowledge of what LINQ can do, but it can't show you everything. Consider this chapter that barest introduction to a much larger topic.

The copy of LINQ that comes with Visual Studio comes with four providers that supply access to standard data sources. These providers include:

  • Objects

  • DataSet

  • SQL

  • XML

This chapter provides very short examples of how to use each of the standard providers. It's important to know, though, that developers are writing LINQ by the gross and you can potentially use LINQ to access just about any data source imaginable (and a few things that most people ...

Get Expert One-on-One™ C# Design and Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.