DescriptionLanguage Integrated Query (LINQ), as well as the C# 3.0 and VB 9.0 language extensions to support it, is the most import single new feature of Visual Studio 2008 and the .NET Framework 3.x. LINQ is Microsoft's first attempt to define a universal query language for a diverse set of in-memory collections of generic objects, entities persisted in relational database tables, and element and attributes of XML documents or fragments, as well as a wide variety of other data types, such as RSS and Atom syndication feeds. Microsoft invested millions of dollars in Anders Hejlsberg and his C# design and development groups to add new features to C# 3.0—such as lambda expressions, anonymous types, and extension methods—specifically to support LINQ Standard Query Operators (SQOs) and query expressions as a part of the language itself. Corresponding additions to VB 9.0 followed the C# team's lead, but VB's implementation of LINQ to XML offers a remarkable new addition to the language: XML literals. VB's LINQ to XML implementation includes XML literals, which treat well-formed XML documents or fragments as part of the VB language, rather than requiring translation of element and attribute names and values from strings to XML DOM nodes and values. This book concentrates on hands-on development of practical Windows and Web applications that demonstrate C# and VB programming techniques to bring you up to speed on LINQ technologies. The first half of the book covers LINQ Standard Query Operators (SQOs) and the concrete implementations of LINQ for querying collections that implement generic IEnumerable
System.Linq.Expressionsnamespaces for LINQ to Objects,
System.Data.Linqfor LINQ to SQL,
System.Data.Linqfor LINQ to DataSet,
System.Xml.Linqfor LINQ to XML, and
System.Web.Entityfor EF's Entity SQL.
- "Taking a New Approach to Data Access in ADO.NET 3.5," uses simple C# and VB code examples to demonstrate LINQ to Objects queries against in-memory objects and databinding with LINQ-populated generic List
DataTables with LINQ to DataSets, creating
EntitySets with LINQ to Entities, querying and manipulating XML InfoSets with LINQ to XML, and performing queries against strongly typed XML documents with LINQ to XSD. "Understanding LINQ Architecture and Implementation," begins with the namespaces and C# and VB language extensions to support LINQ, LINQ Standard Query Operators (SQOs), expression trees and compiled queries, and a preview of domain-specific implementations. C# and VB sample projects demonstrate object, array, and collection initializers, extension methods, anonymous types, predicates, lambda expressions, and simple query expressions. "Executing LINQ Query Expressions with LINQ to Objects," classifies the 50 SQOs into operator groups: Restriction, Projection, Partitioning, Join, Concatenation, Ordering, Grouping, Set, Conversion, and Equality, and then lists their keywords in C# and VB. VS 2008 SP1 includes C# and VB versions of the LINQ Project Sample Query Explorer, but the two Explorers don't use real-world collections as data sources. This describes a LINQ in-memory object generator (LIMOG) utility program that writes C# 3.0 or VB 9.0 class declarations for representative business objects that are more complex than those used by the LINQ Project Sample Query Explorers. Sample C# and VB queries with these business objects as data sources are more expressive than those using a arrays of a few integers or last names. "Working with Advanced Query Operators and Expressions," introduces LINQ queries against object graphs with entities that have related (associated) entities. This begins with examples of aggregate operators, explains use of the
Lettemporary local variable operator, shows you how to use
Group Bywith aggregate queries, conduct the equivalent of left outer joins, and take advantage of the
Contains()SQO to emulate SQL's
IN()function. You learn how to compile queries for improved performance, and create mock object classes for testing without the overhead of queries against relational persistence stores. "Using LINQ to SQL and the LinqDataSource," introduces LINQ to SQL as Microsoft's first O/RM tool to reach released products status and shows you how to autogenerate class files for entity types with the graphical O/R Designer or command-line
SqlMetal.exe. This also explains how to edit
*.dbmlmapping files in the Designer or XML Editor, instantiate
DataContextobjects, and use LINQ to SQL as a Data Access Layer (DAL) with T-SQL queries or stored procedures. Closes with a tutorial for using the ASP.NET LinqDataSource control with Web sites or applications. "Querying DataTables with LINQ to DataSets," begins with a comparison of
DataContextobjects and features, followed by a description of the
DataSetExtensions. Next comes querying untyped and typed DataSets, creating lookup lists, and generating
LinqDataViews for databinding with the
AsDataView()method. This ends with a tutorial that shows you how to copy LINQ query results to
DataTables. "Manipulating Documents with LINQ to XML," describes one of LINQ most powerful capabilities: managing XML Infosets. This demonstrates that LINQ to XML has query and navigation capabilities that equal or surpasses XQuery 1.0 and XPath 2.0. It also shows LINQ to XML document transformation can replace XQuery and XSLT 1.0+ in the majority of common use cases. You learn how to use VB 9.0's XML literals to constructs XML documents, use
GroupJoin()to produce hierarchical documents, and work with XML namespaces in C# and VB. "Exploring Third-Party and Emerging LINQ Implementations," describes Microsoft's Parallel LINQ (also called PLINQ) for taking advantage of multiple CPU cores in LINQ to Objects queries, LINQ to REST for translating LINQ queries into Representational State Transfer URLs that define requests to a Web service with the HTML GET, POST, PUT, and DELETE methods, and Bart De Smet's LINQ to Active Directory and LINQ to SharePoint third-party implementations. "Raising the Level of Data Abstraction with the Entity Data Model," starts with a guided tour of the development of EDM and EF as an O/RM tool and heir apparent to ADO.NET DataSets, provides a brief description of the entity-relationship (E-R) data model and diagrams, and then delivers a detailed analysis of EF architecture. Next comes an introduction to the Entity SQL (eSQL) language, eSQL queries, client views, and Object Services, including the
ObjectStateManager. Later chapters describe eSQL and these objects in greater detail. Two C# and VB sample projects expand on the eSQL query and Object Services sample code. "Defining Conceptual, Mapping, and Storage Schema Layers," provides detailed insight into the structure of the
*.edmxfile that generates the
*.ssdl(storage schema data language),
*.msl(mapping schema language), and
*.csdlfiles at runtime. You learn how to edit the *.edmx file manually to accommodate modifications that the graphic EDM Designer can’t handle. You learn how to implement the Table-per-Hierarchy (TPH) inheritance model and traverse the MetadataWorkspace to obtain property values. Four C# and VB sample projects demonstrate mapping, substituting stored procedures for queries, and TPH inheritance. "Introducing Entity SQL," examines EF's new eSQL dialect that adds keywords to address the differences between querying entities and relational tables. You learn to use Zlatko Michaelov's eBlast utility to write and analyze eSQL queries, then dig into differences between eSQL and T-SQL
SELECTqueries. (eSQL v1 doesn't support
DELETEand other SQL Data Manipulation Language constructs). You execute eSQL queries against the
EntityClient, measure the performance hit of eSQL compared to T-SQL, execute parameterize eSQL queries, and use SQL Server Compact 3.5 as a data store. C# and VB Sample projects demonstrate the programming techniques.
- "Taking Advantage of Object Services and LINQ to Entities," concentrates manipulating the Object Services API's
ObjectContext. It continues with demonstrating use of partial classes for the
EntityNameobjects, executing eSQL
ObjectQuerys, and deferred or eager loading of associated entities, including ordering and filtering the associated entities. Also covers instructions for composing QueryBuilder methods for
ObjectQuerys, LINQ to Entities queries, and parameterizing
ObjectQuerys. "Updating Entities and Complex Types," shows you how to perform create, update, and delete (CUD) operations on
EntitySets and manage optimistic concurrency conflicts. It starts with a detailed description of the
ObjectContext.ObjectStateManagerand its child objects, which perform object identification and change tracking operations with
EntityKeys. This also covers validation of create and update operations, optimizing the
DataContextlifetime, performing updates with stored procedures, and working with complex types. "Binding Data Controls to the ObjectContext", describes creating design-time data sources from
ObjectContext.EntitySetinstances, drag-and-drop addition of
DataGridViewcontrols to Windows forms. You also learn how to update
DataGridViewcontrols. (You can’t update
EntitySetvalues directly; you must delete and add a new member having the required value). This concludes with a demonstration of the use of the ASP.NET
EntityDataSourcecontrol bound to
1. Taking a New Approach to Data Access in ADO.NET 3.5.
II. Introducing Language Integrated Query.
2. Understanding LINQ Architecture and Implementation.
3. Executing LINQ Query Expressions with LINQ to Objects.
4. Working with Advanced Query Operators.
III. Applying Data Source-Specific LINQ Implementations.
5. Using LINQ to SQL and the LinqDataSource.
6. Querying DataTables with LINQ to DataSets.
7. Manipulating and Linking Documents with LINQ to XML.
8. Exploring Third-Party and Emerging LINQ Implementations.
IV. Introducing the ADO.NET Entity Framework.
9. Raising the Level of Data Abstraction with the Entity Data Model.
10. Defining Conceptual, Mapping, and Storage Schema Layers.
11. Introducing the Object Services Layer and Entity SQL.
12. Taking Advantage of LINQ to Entities.
V. Implementing the Entity Data Model.
13. Generating Mapping Metadata with the EDM Designer.
14. Binding Data Controls to the ObjectContent.
15. Updating the Persistence Layer.
|Additional Code Chapter 1||Download|
|Additional Code Chapter 2||Download|
|Additional Code Chapter 3||Download|
|Additional Code Chapter 4||Download|
|Additional Code Chapter 5|
Revised version posted 8/18/09 that contains the missing VB version of the LinqToSqlDataboundControls.
|Additional Code Chapter 6||Download|
|Additional Code Chapter 7||Download|
|Additional Code Chapter 8||Download|
|Additional Code Chapter 9||Download|
|Additional Code Chapter 10||Download|
|Additional Code Chapter 11||Download|
|Additional Code Chapter 12||Download|
|Additional Code Chapter 13||Download|
|Additional Code Chapter 14||Download|
|Additional Code Chapter 15||Download|
|4||Error in Text|
|4||Typo in Text|
|6||Error in Text|
SQO - sor
SQO - or
|6||Typo in Text|
preference is give
preference is given
|8||Error in Text|
|11||Error in Code|
.Count > 9
.Count > 10
|14||Error in Code|
.Count > 9
.Count > 10
|15||Error in Text|
In the italicized text (indented paragraph 2nd from the bottom) it states:
You'll find instructions for attaching...in the "Setting Up the Northwind Sample Database" section of this book's introduction.
This sentence should be deleted, as the section is not in the introduction.
|92||Error in Text|
|92||Error in Text|
Twice on the same line:
|94||Error in Text|
Group Join, Skip
|94||Error in Text|
(select c from customers)
(for c in customers)
|96||Error in Text|
|109||Error in Code|
o => o.Orders
c => c.Orders
|111||Error in Code|
(PageNum-1) * PageSize)
((PageNum-1) * PageSize)
|115||Error in Text|
Should just be
|115||Error in Text|
Should just be
|254||Typo in Text|
implent languages implemented languages
|258||Error in Code|
|317||Typo in Text|
release first release
|319||Typo in Text|
|319||Typo in Text|
|373||Error in Text|
On the bottom of the page:
The <edmx:ConceptualModel> group
The <edmx:Mappings> group
In the first instance in the sentence
|412||Error in Text|
In the middle of the page:
|451||Error in Text|
At the top of the page:
applying the GROUP BY
applying the ORDER BY
|569||Typo in Text|
|571||Typo in Text|
|573||Typo in Text|