Appendix A. Understanding LINQ

 

You’re likely already familiar with the various C# and Visual Basic language innovations and their importance in bringing LINQ to life. But if you haven’t come across LINQ yet, this appendix will introduce you to the project and enumerate its advantages, its requirements in terms of language modifications, and its vision. This is important, because the main query language in Entity Framework is LINQ to Entities, which in the end is a LINQ dialect. Having a solid knowledge of LINQ’s foundations will help you understanding LINQ to Entities queries.

In the first part of this appendix, we’ll cover the reasons why the Microsoft architects decided to embed query extensions into the language, and the broad vision of the LINQ platform. After that, we’ll introduce the features that have made LINQ a success. These features are the language innovations that have been introduced in C# 3.0 and VB 9. There are lots of innovations to cover, so this will be a long discussion.

By the end of the appendix, you’ll be able to fully understand and write any LINQ query.

A.1. Why was LINQ created?

Each data technology has its own language for performing queries. Data from databases can be pulled out using SQL commands; XML data can be retrieved using the XPath syntax; even Active Directory and ADO.NET DataTable information can be accessed using their own syntaxes.

A.2. Type inference

A.3. Extension methods

A.4. Lambda expressions

A.5. Object initializers

A.6. Anonymous types

A.7. Query syntax

A.8. Deferred execution

sitemap