Chapter 24. Applying LINQ

WHAT YOU WILL LEARN IN THIS CHAPTER

  • LINQ varieties

  • Using LINQ with databases

  • Navigating database relationships

  • Using LINQ with XML

  • Using LINQ to XML constructors

  • Generating XML from databases

  • Working with XML fragments

The previous chapter introduced LINQ (Language-Integrated Query) and showed how LINQ works with objects. This chapter will teach you how to apply LINQ to queries and manipulate data from different data sources such as databases and XML (Extensible Markup Language).

LINQ VARIETIES

Visual Studio 2010 and the .NET Framework 4 come with a number of built-in LINQ capabilities that provide query solutions for different types of data:

  • LINQ to Objects: Provides queries on any kind of C# in-memory object, such as arrays, lists, and other collection types. All of the examples in the previous chapter use LINQ to Objects. However, you can use the techniques you learn in this chapter with all of the varieties of LINQ.

  • LINQ to XML: Provides creation and manipulation of XML documents using the same syntax and general query mechanism as the other LINQ varieties.

  • LINQ to ADO.NET: ADO.NET or Active Data Objects for .NET is an umbrella term that includes all the different classes and libraries in .NET for accessing data in databases, such as Microsoft SQL Server, Oracle, and others. LINQ to ADO.NET includes LINQ to Entities, LINQ to DataSet, and LINQ to SQL.

  • LINQ to Entities: The ADO.NET Entity Framework is the newest set of data interface classes in .NET 4, recommended ...

Get Beginning Visual C# 2010 now with O’Reilly online learning.

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