Projection Using the Select Clause
Now that we’ve identified the query sources, we can start operating on the data they provide. Although you might think of filtering and ordering as the first kind of operations you want to perform, we’ll start from the end. Every query expression in C# needs to end either by a select
clause or a group by
clause. The former operation is the simplest to explain, so we start from there.
Identity Projection
The most trivial projection possible doesn’t do any transformation on the input data and is called the identity projection, after the identity function. An example is shown here:
var nums = new List<int> { 1, 2, 3, 4, 5 };var res = from n in nums select n;
This produces ...
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.