O'Reilly logo

Programming .NET 3.5 by Jesse Liberty, Alex Horovitz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Understanding LINQ: Queries As First-Class Language Constructs

One of the tasks programmers typically perform every day is finding and retrieving objects in memory, a database, or an XML file. For example, you may be developing an application to allow your customers to keep track of all their music purchases from various sources (e.g., online, brick and mortar shops, or one another) and where their music is stored. To accomplish this, you’ll need to retrieve data from multiple sources (e.g., iTunes, various online sites, and computers on your network), and to filter that information by numerous and changing criteria (name, month, cost, artist, last-listened-to date, etc.).

In the past, you might have implemented all of this by uploading all your data into a relational database and then querying that database using Transact-SQL. Unfortunately, the data is likely to change frequently (in some families, hourly!). Also, much of it will already be available to you, though not natively in a database; it will be available through web services and other data sources.

The traditional .NET Framework approach using ADO.NET does not lend itself to easily aggregating and searching disparate data sources. In-memory searches lack the powerful and flexible query capabilities of SQL, while ADO.NET is not integrated into C#, and SQL itself is not object-oriented (in fact, the point of ADO.NET was to bridge the gap between the object and relational models).

To solve these and other issues, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required