FREE BOOK

Chapter 8 : Reading Objects with LINQ to SQL

Posted by Addison Wesley Free Book | LINQ July 28, 2009
It uses the mapping of classes to tables to translate LINQ queries to SQL commands and then materializes objects from the rows returned. The objects can be related to each other in a graph of objects that is managed by LINQ to SQL on your behalf.

Summary
 
This chapter covered the details of reading objects with LINQ to SQL. LINQ queries are translated into SQL using mapping information for classes and relationships between classes. Mapped classes can be used to retrieve entities or projections. Relationships can be expressed as mapped properties that can be navigated using the dot or through joins. The target of a relationship can be loaded lazily or eagerly. Like relationships, inheritance is also supported by LINQ to SQL for a class hierarchy mapped to a table. The distinction between a query with deferred execution and a cached result is a key to understanding the performance implications. Query performance can be significantly boosted by using compiled queries, which can be effectively cached in a web application. Finally, LINQ to SQL exclusively uses parameters to avoid SQL injection attacks. Thus, LINQ to SQL is a high-performance tool that provides a rich and relatively secure way to read objects from a database.
 

Total Pages : 9 56789

comments