A thank you to each of you for letting me ask questions and providing excellent feedback.
It has been said that you are only as good as those with whom you associate. So enough cannot be said
about the love and support of my family, for without them, this book, or anything else I do in life, would
not be possible. My wonderful wife, Lynelle, who during these times is an anchor for this family, held
the house together for the 8+ months I spent upstairs writing. And to my children, who were patient
with their father knowing that they soon would get their dad back. I love you all. When did my eldest
daughter turn old enough to start driving?
Contents
Acknowledgments xiii
Introduction xxiii
Part I: Introduction to Project LINQ
Chapter 1: Project LINQ 3
LINQ Overview 7
Standard Query Operators 10
LINQ to XML Overview 12
LINQ to SQL Overview 14
Summary 16
Chapter 2: A Look at Visual Studio 2008 17
Visual Studio 2008 17
Language-Specific LINQ Features 21
Query Expressions 21
Implicitly Typed Variables 22
Anonymous Types 23
Initializers for Objects and Collections 23
Extension Methods 26
Lambda Expressions 28
Summary 30
Chapter 3: LINQ Queries 31
Introduction to LINQ Queries 31
Data Source 32
Query Creation 33
Query Execution 33
Likened to SQL Syntax 36
Query Concepts 37
Var versus IEnumerable 40
Common Query Terms 41
IQueryable and IQueryable(Of T) Interfaces 42
Contents
Query Syntax versusMethod Syntax 43
Which Do You Use? 44
Using Query and Method Syntaxes 45
Summary 51
Chapter 4: LINQ Standard Query Operators 53
Overview 53
Standard Query Operators 54
Projection Operators 55
Restriction Operator 57
Sorting Operators 57
Joining Operators 59
Grouping Operator 62
Concatenating Operator 63
Aggregating Operators 64
Set Operators 68
Generation Operators 71
Conversion Operators 73
Element Operators 77
Equality Operators 82
Quantifier Operators 83
Partitioning Operators 86
Putting Query Operators toWork 88
Summary 92
Part II: LINQ to XML
Chapter 5: Understanding LINQ to XML 95
LINQ to XML Overview 95
LINQ to XML Programming Fundamentals 96
LINQ to XML Classes 96
XElement Class 98
XAttribute Class 102
XDocument Class 104
LINQ to XML Programming Concepts 107
Working with Existing XML 107
Saving XML to LINQ to XML 109
Creating XML 110
xvi
Contents
Traversing XML 111
Manipulating XML 112
Working with Attributes 117
LINQ to XML versus Other XML Technologies 120
LINQ to XML versus DOM 120
LINQ to XML versus XmlReader 121
LINQ to XML versus XSLT 121
LINQ to XML versus MSXML 121
Summary 122
Chapter 6: Programming with LINQ to XML 123
Creating Trees 123
Creating Trees in C# 124
Creating Trees in Visual Basic 128
Populating Trees from Text 130
Querying XML Trees 132
Modifying and Reshaping XML Trees 137
Serializing XML Trees 139
Namespaces 141
Summary 143
Chapter 7: LINQ to XML and Other LINQ Data Models 145
SQL to XML 145
XML to SQL 149
Insert 150
Update 151
Summary 152
Chapter 8: Advanced LINQ to XML Programming Topics 153
LINQ to XML Functional Construction 153
LINQ to XML Annotations 158
LINQ to XML Axis 161
Ancestors 161
Descendants 163
AncestorsAndSelf 164
DescendantsAndSelf 165
ElementsAfterSelf and ElementsBeforeSelf 166
LINQ to XML Events 167
Changing 168
Changed 170
xvii
Contents
Streaming XML Documents 171
Streaming Large XML Documents 176
Summary 177
Chapter 9: LINQ to XML and Visual Basic .
Pages:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25