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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.