_Categories.Entity; }
set { this._Categories.Entity = value; }
}
public Items() { this._Categories = new EntityRef
(); }
}
The above code creates mapping of:
1. Deserts class to the Deserts SQL database. This class is of type
DataContext.
2. Categories class to the Categories SQL database object in the Deserts
database.
3. Items class to the Items SQL database object in the Deserts database.
We also need to have primary and foreign keys defined for these classes.
Now open the Default.aspx designer and add the following controls to build the
web page:
1. Add the HTML table to design the UI.
2. Add a Label and a DropDownList to the page for categories selection.
Appendix A
[ 225 ]
3. Add a button control to execute LINQ queries, and bind the results to the
GridView control.
4. Add a GridView control to show List of Items for the selected category in
the drop down list.
5. Add a Label and a TextBox control to show Total Items for the selected
category.
After adding all the controls to the web page, it would look like this:
The columns shown in GridView correspond to the details that will be fetched for
the selected category using LINQ queries.
Pages:
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329