The following code queries the Person.Contact table of the Adventureworks database as defined in the
object mapping:
var query =
(from c in contact
where c.FirstName.StartsWith("S")
&& c.LastName.StartsWith("K")
orderby c.LastName
select c);
As with the other components of LINQ, LINQ to SQL works with both C# and Visual Basic. LINQ to
SQL also supports stored procedures and user-defined functions. However, to fully understand LINQ
to SQL, the LINQ to SQL object model and the concept of attribute-based mapping must be explored.
LINQ to SQL Object Model
The LINQ to SQL object model provides the fundamental elements for working with and managing
relational objects. It is via this model that a relational model is mapped to and expressed in the
developer??™s programming language.
In the LINQ to SQL object model, database commands are not issued against the database directly. As a
developer, you simply change values and execute methods within the confines of the object model. LINQ
to SQL then translates those changes or methods into the appropriate SQL commands and funnels them
through to the database to be executed.
Pages:
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333