Chapter 30Language Integrated Queries (LINQ) Code Downloads for this Chapter

The code downloads for this chapter are found at on the Download Code tab. The code and any related support files are located in their own folder for this chapter.

Language Integrated Queries (LINQ) was designed to provide a common programming model for querying data. In this chapter you see how you can take some verbose, imperative code and reduce it to a few declarative lines. This enables you to make your code more descriptive rather than prescriptive; that is, describing what you want to occur, rather than detailing how it should be done.

Although LINQ provides an easy way to filter, sort, and project from an in-memory object graph, it is more common for the data source to be either a database or a file type, such as XML. In this chapter you are introduced to LINQ to XML, which makes working with XML data dramatically simpler than with traditional methods such as using the document object model, XSLT, or XPath. You also learn how to use LINQ to SQL to work with traditional databases, such as SQL Server, enabling you to write LINQ statements that can query the database, pull back the appropriate data, and populate .NET objects that you can work with. In Chapter 31, “The ADO.NET Entity Framework,” ...

Get Professional Visual Studio 2015 now with the O’Reilly learning platform.

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