Building a Simple Storefront with LINQ - ProductCategory Table
(Page 2 of 4 )
Next, take a look at the ProductCategory table, which stores the various categories that products may be arranged in:

The table is simple enough. Each category has a ProductCategoryID field which identifies it, along with a Name field. No surprises. What interests us here is the ParentProductCategoryID field. Top-level categories won't have any value in this field (which is why "Allow Nulls" is checked for this field), but a subcategory will have the ProductCategoryID of its parent category in this field. Our sample database only has two category levels, top-level categories, which only contain other categories, and subcategories, which contain the products, so it won't be too difficult to work with this table.
Recall how the Product table defined a ProductModelID field. Each product can be modeled after a product model. For example, say we have a product model called Mountain-100, representing a mountain bike. From this model, we can have, for example, various colors. A product, then, might be named Mountain-100 Silver, or Mountain-100 Black. Let's look at the ProductModel table:

Each model has a ProductModelID field and a Name field, both serving to identify it, as well as a CatalogDescription field. We won't be using this field. Instead, we'll be using descriptions from the ProductDescription table:

The ProductModelProductDescription table provides a link between the ProductModel table and the ProductDescription table by matching a ProductModelID with a ProductDescriptionID:

The Plan
We're not building anything complex here-only enough to demonstrate LINQ through ASP.NET. So, our plan will be quite simple. We'll create a master page to unify the site's layout. The master page will just feature the title of our site, Adventure Works Cycles. Then, we'll create a home page that displays information about some of the latest items added to the database. However, this information will have to include a picture of the item, so we'll need to create a page that displays a given item's picture.
Next, we'll create a page where a user can browse all of the products in the store. One ListBox will provide a list of top-level categories from which the user can choose, and another ListBox will provide a list of subcategories corresponding to the chosen top-level category. When a subcategory is shown, a list of all the items in that category will be displayed.
However, displaying all of the products in a given category might not be what we want, so after we complete the basic product browse functionality, we'll create an alternative browse page, this time browsing all of the product models in a given category.
Next: Creating the Master Page >>
More ASP.NET Articles
More By Peyton McCullough