Chapter 13. LINQ

If I had to choose my favorite new feature in .NET 3.5, I'd probably pick LINQ, the new query language that is tightly integrated with the programming languages used in the .NET Framework. LINQ stands for language-integrated query and enables you to query data from within .NET programming languages similar to how SQL allows you to query data in a database. In fact, the LINQ syntax has been modeled partially after the SQL language, making it easier for programmers familiar with SQL to get started with LINQ.

LINQ comes in a few different implementations, allowing you to access and query a wide variety of sources including collections in your own code, XML files, .NET DataSets, and SQL Server databases from your VB.NET or C# code. In the next section you get a brief overview of the main LINQ pillars while the remainder of the chapter focuses on that part of LINQ that enables you to query Microsoft SQL Server databases, called LINQ to SQL.

In addition to the LINQ syntax that is now part of the two most popular programming languages, C# and Visual Basic, the .NET 3.5 Framework ships with a few additional tools that make using LINQ in your projects a smooth experience.

Additionally, the new LinqDataSource control allows you to hook up data-bound controls to LINQ-compatible data sources directly. You'll see how to consume and configure this control in the second half of this chapter.

This chapter introduces you to both the LINQ language and its syntax, as well as to ...

Get Beginning ASP.NET 3.5: In C# and VB 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.