categoryID");
The output of the query will be assigned to the Items object.
Query Result
We can visually see the query text that actually gets executed at the database. LINQ to
SQL takes the query expression and converts it to a database equivalent query. This
tool helps us to see the query generated by LINQ to SQL for the query expression.
For example, consider the following simple query and try to execute it.
// Normal way of writing joins between two tables
var qry = from cat in db.Categories
join items in db.Items on cat.CategoryID equals items.CategoryID
where cat.Category == "Icecreams"
select items;
After assigning the query expression to the qry variable, if you place the mouse
pointer over qry, we will get the query text, shown as follows:
LINQ to SQL
[ 110 ]
The full text of the T-SQL query generated by LINQ to SQL would be this:
{SELECT [t1].[ItemID], [t1].[CategoryID], [t1].[Name],
[t1].[Ingredients], [t1].[ServingSize], [t1].[TotalFat],
[t1].[Cholesterol], [t1].[TotalCarbohydrates], [t1].
Pages:
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186