Home > Articles > Programming > Windows Programming

LINQ Query Expressions

  • Print
  • + Share This
Learn seven different types of query expression clauses and explains the four ways in which they introduce range variables.
This chapter is from the Rough Cut version of the book.

This chapter is from the book

This chapter is from the book

This chapter explores the various rules and syntactical elements that define the structure of LINQ query expressions. The text covers the seven different types of query expression clauses and explains the four ways in which they introduce range variables. In the next chapter, you will read about the 47 different LINQ operators that can play 14 different roles in a query expression.

This chapter analyzes the structure of query expressions. It is divided into 5 main sections and various subsections:

  1. Syntactical Analysis
    1. Nomenclature
    2. Clauses
    3. Range Variables
    4. Projections
  2. Composing Queries
    1. Group-by clauses
    2. The into keyword
    3. Let clauses
  3. Projections
    1. The Role of Projections
    2. Projections and Deferred Execution
    3. Projections with SelectMany
    4. The SelectMany Overloads
  4. Query Expressions and other Flavors of LINQ
    1. LINQ to MyNumberServer
    2. Thinking about IQueryable
  5. Summary

Query Expression Syntax

Though query expressions are both the topic of this chapter, and a central theme in LINQ, it is important to remember that they exist simply to provide us with an easy way to write queries; behind the scenes they are always translated back into query method syntax. Nevertheless, query expressions are the most common, the easiest, and the recommended way to write LINQ queries.

From the user's perspective, query expressions exist because we need an easy to use, easy to understand syntax for writing queries. From a purely technical perspective, however, query expressions are simply a machine for creating query methods. When we write a query expression, the compiler applies simple rules to it, and converts it into code that follows the query method syntax.

  • + Share This
  • 🔖 Save To Your Account