O'Reilly logo

Beginning Microsoft® Visual C#® 2008 by Eric White, Morgan Skinner, Jon D. Reid, Jacob Hammer Pedersen, Christian Nagel, Karli Watson

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 27. LINQ to SQL

The previous chapter introduced LINQ (Language-Integrated Query) and showed how to use LINQ to Objects, the version of LINQ that works with objects in memory. This chapter explores LINQ to SQL, the version of LINQ that provides access to SQL (pronounced "sequel") databases such as Microsoft SQL Server and Oracle.

These databases use the SQL database language (SQL stands for Structured Query Language) to query and manipulate their data. Traditionally, working with such a database required knowing at least some SQL, either embedding SQL statements in your programming language or passing strings containing SQL statements to API calls or methods in a SQL-oriented database class library.

Sounds complicated, doesn't it? Well, the good news is that LINQ to SQL handles all the details of communicating with the SQL database for you! It translates your LINQ queries to SQL statements automatically and enables you and your programs to work simply with C# objects.

Visual C# 2008 provides designers that create LINQ to SQL classes for you from the existing database, and provides a simple way to bind the controls in your forms to your databases graphically, so that a full database application can be created quickly and easily with very little handwritten code.

You will see how this works as you step through the examples in this chapter. In particular, you look at the following:

  • The concept of object-relational mapping (ORM) and how LINQ to SQL provides it.

  • How to install SQL Server ...

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