O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required