O'Reilly logo

Professional ADO.NET 3.5 with LINQ and the Entity Framework by Roger Jennings

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

Chapter 3. Executing LINQ Query Expressions with LINQ to Objects

LINQ to Objects is Visual Studio 2008's core LINQ implementation for querying in-memory objects. All other Microsoft and third-party LINQ implementations use the same or a subset of the LINQ to Objects query expression syntax because the query keywords are part of the C# 3.0 and VB 9.0 languages. The two language compilers translate LINQ to Objects query expressions into the method call syntax, which chains keyword extension methods to an IEnumerable<T> type. The extension methods use lambda expressions as parameters. Chapter 2's "Standard Query Operators" section gave you an overview of the translation to method call process. The compilers translate the lambda expressions to anonymous methods and use anonymous type syntax to auto-generate private classes that compile to .NET Intermediate Language (MSIL). The syntax and code examples in this and the next chapter operate on IEnumerable<T> and IOrderedEnumerable<T> types that the compiler processes by this rather roundabout approach.

Some writers refer to LINQ's method call syntax as explicit syntax. However, calling methods to which you assign lambda expressions as predicates is no more explicit than query expressions based on keywords; both query dialects compile to the same MSIL. In fact, keyword-based query expressions probably are more explicit than method calls because they're easier for human beings to read and interpret.

Microsoft's LINQ to SQL, LINQ to DataSets, ...

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