You know this is an
anonymous query expression because of the use of the var keyword discussed previously.
A portion of the preceding code defines the second and third actions of a query operation. The query
expression (the second action) defines the information to be retrieved from the data source, while the
execution of the query (the iteration over the query variable) is the last action.
Press F5 to compile and run the application. When the form opens, click the Query Syntax button.
The list box will populate with the first names, last names, and email addresses of those contacts
who meet the criteria specified in the query expression. The results on your form should look like those
in Figure 3-4.
48
Chapter 3: LINQ Queries
Figure 3-4
In this example, the select clause in the query expression did not select individual properties from the
query results, but rather selected all the properties by simply stating select c. This is similar to stating
SELECT * FROM in T-SQL syntax. Because all the properties were selected to be returned, all properties are
available from IntelliSense, as shown in Figure 3-5.
Pages:
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115