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

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