Continuing a Query Expression Using the into Clause

Although most query expression clauses can be followed by others immediately, there are a few notable exceptions. In particular, select and group by end a query expression because of their projective characteristic. For example:

var query = from product in products            select new { product.Name, product.Price };

Once the projection has happened, the query expression produces objects of the type used in the select clause. In this particular example, that’s an anonymous type with two properties: Name and Price. At this point, we don’t have an identifier anymore to refer to those objects: If product would still be “in scope,” we could get access to properties ...

Get C# 5.0 Unleashed 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.