SQL Translation

When writing LINQ to SQL queries, you may have noticed that when specifying expressions such as where clauses, the expressions are in the native programming language, as opposed to SQL. After all, this is part of the goal of LINQ, language integration. For this book, the expressions are in C#. If you haven't noticed, shame on you.

For example, in Listing 14-2, I have a query that looks like this:

Example. An Example of a LINQ to SQL Query
Customer cust = (from c in db.Customers
                 where c.CustomerID == "LONEP"
                 select c).Single<Customer>();

Notice that the expression in the where clause is indeed C# syntax, as opposed to SQL syntax that would look more like this:

Example. An Example of an Invalid LINQ to SQL Query
Customer cust ...

Get Pro LINQ: Language Integrated Query in C# 2008 now with O’Reilly online learning.

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