LINQ to Objects Extension Methods

From a language point of view, LINQ is nothing but the syntactical surface provided through so-called query expressions, as we’ve seen before. Those map onto method calls originating from the various translation schemes that we saw. For example:

var query = from x in xs            where x % 2 == 0            select x + 1;

The preceding turns into the following:

xs.Where(x => x % 2 == 0).Select(x => x + 1)

This is all there is to LINQ from the language perspective. The methods targeted by the query expressions are collectively known as the query pattern. Any type that somehow exposes those methods obeys the query pattern and works with the query expression syntax integrated in languages such as C# and Visual Basic. ...

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.