Chapter 4. Getting familiar with LINQ to Objects

 

This chapter covers:

  • The LinqBooks running example
  • Querying collections
  • Using LINQ with ASP.NET and Windows Forms
  • Major standard query operators

In chapter 1 we introduced LINQ, and in chapters 2 and 3 we described new language features and LINQ concepts. We’ll now sample each LINQ flavor in turn. This part focuses on LINQ to Objects. We’ll cover LINQ to SQL in part 3, and LINQ to XML in part 4.

The code samples you’ll encounter in the rest of this book are based on a running example: a book cataloging system. This chapter starts with a description of this example application, its database schema, and its object model.

We’ll use this sample application immediately as a base for discovering LINQ to Objects. We’ll review what can be queried with LINQ to Objects and what operations can be performed.

Most of what we’ll show you in this chapter applies to all LINQ flavors and not just LINQ to Objects. We’ll focus on how to write language-integrated queries and how to use the major standard query operators. The goal of this chapter is that you become familiar with query expressions and query operators, as well as feel comfortable using LINQ features with in-memory object collections.

4.1. Introducing our running example

4.2. Using LINQ with in-memory collections

4.3. Using LINQ with ASP.NET and Windows Forms

4.4. Focus on major standard query operators

4.5. Creating views on an object graph in memory

4.6. Summary