Chapter 7. Peeking under the covers of LINQ to SQL

 

This chapter covers:

  • Mapping from the database to objects
  • Exploring how LINQ to SQL works under the covers
  • Translating query expressions into SQL with IQueryable and expression trees
  • Tracking objects through their life cycle
  • Working with disconnected data

In chapter 6, we presented a high-level view of some of the capabilities of LINQ to SQL. By now, you should have enough tools under your belt to start working with LINQ to SQL.

In this chapter, we dive a bit deeper and explore how the technology works under the covers. We’ll start by looking at the mapping options at our disposal. We explain not only the mapping options, but also how to employ some of the tools that come with Visual Studio 2008 to make mapping easier. We’ll continue by looking at the underlying technologies that make LINQ to SQL behave differently from LINQ to Objects. We won’t have enough time to create our own O/R mapper, but we’ll discuss how they differ at their core. We’ll conclude this chapter by examining the object life cycle and see how LINQ to SQL manages the objects through their changes until they are updated. By combining the mapping, translations, and object life cycle, LINQ to SQL emerges as a powerful extension of the LINQ family of technologies.

7.1. Mapping objects to relational data

7.2. Translating query expressions to SQL

7.3. The entity life cycle

7.4. Summary