Solution Overview

This topic provides a high-level overview of the various components that make up the SharePoint List Data Models reference implementation. It does not examine the design of the solution or the implementation details of specific features, as these are described later in this guidance. Instead, it illustrates how the reference implementation works at a conceptual level.

Data Model Components

The data model in this implementation is based on the parts management database described in the External Data Models reference implementation. It illustrates how you can use SharePoint lists to provide similar functionality to that of a relational database. The following image shows the entity-relationship diagram for the parts management data model.

The Parts Management Data Model


The reference implementation uses various SharePoint data and logic constructs to implement this data model. It uses:

  • List instances to represent each physical table in the data model.
  • Site columns to represent the fields in the data model. These include lookup columns, which form the basis of relationships between lists.
  • Content types to represent the entities in the data model. Content type bindings are used to associate each content type with its eponymous list.
  • Feature event receivers to programmatically set the delete behavior on list relationships.
  • List item event receivers to programmatically ensure that new or updated items are unique.
  • Entity classes that represent the lists and list items in the data model. These were generated by the SPMetal command-line tool and enable you to use the LINQ to SharePoint provider to query SharePoint list data.

User Interface Components

The SharePoint List Data Models reference implementation includes several custom Visual Web Parts that allow you to query and manipulate the parts management data. These Web Parts rely on a central data repository class that uses LINQ to SharePoint to perform operations on the underlying SharePoint list data. The use of a centralized repository class consolidates all of the data operations into one place for ease of maintenance, and reduces the amount of code duplication across the solution. As the focus of this implementation is on how to access and manipulate SharePoint list data, it is also beneficial to abstract out this data access logic from the user interface implementation details of the Web Parts.

When you deploy the SharePoint List Data Models reference implementation, the installer creates a new site collection named SharePointList and deploys and activates all the features within the solution. One of these features, the Web-scoped Navigation feature, adds a number of links to the site Quick Launch bar, as shown in the following diagram.

Navigating the SharePoint List Data Models reference implementation


You can use these links to explore the pages in the reference implementation. Each page includes a Visual Web Part that interacts with the underlying data store in a different way.

  • The Manage Categories, Manage Departments, Manage Parts, Manage Machines, Manage Manufacturers, Manage Suppliers, and Manage Inventory pages allow you to search for each type of data entity, view detailed records, browse related items, create new items, and edit or delete existing items.
  • The Search Administration page provides more sophisticated functionality for finding parts. You can search by machine model number or part SKU, or you can browse for parts by category, department, or manufacturer.

The functionality contained within these Web Parts and the data repository class is discussed in more detail as we take a look at specific areas of functionality in the topics that follow.

Browsing the Visual Studio Solution

The Microsoft Visual Studio® 2010 solution for the SharePoint List Data Model reference implementation contains two projects.

  • The DataModels.SharePointList.Model project contains the components that implement the parts management data model, and include SharePoint lists, site columns, content types, and event receivers.
  • The DataModels.SharePointList.PartsMgmnt project contains the components that allow users to interact with the data model, and include Visual Web Parts together with supporting components such as ViewModel classes and a LINQ to SharePoint repository class.

The following diagram shows the structure of the DataModels.SharePointList.Model project in Solution Explorer.

The DataModels.SharePointList.Model Project


The key components of this project are as follows:

  • The SharePointListLIs node contains a feature manifest file that provisions a list instance for each entity in the data model. These are standard custom lists and do not define any columns.
  • The SharePointListCTs node contains a feature manifest file that defines columns and content types. It defines a column for each field in the data model and a content type for each entity in the data model. The content types that represent join tables in the model—Machine Department, Machine Part, and Part Supplier—register the UniqueListItemEventReceiver class for ItemAdding and ItemUpdating events. This ensures that all items in these join lists are unique.
  • The SharePointListCT2LI node contains a feature manifest file that binds each content type to its respective list.
  • The ListEvntReceivers node contains the UniqueListItemEventReceiver class. As described above, this ensures that new or updated items in lists that represent join tables are unique. The methods in the UniqueListItemEventReceiver class use the ListItemValidator class to verify uniqueness when items are added or updated.
  • The PartsSite.cs file contains entity classes that provide a strongly-typed representation of the SharePoint lists and list items in the data model. These classes are used to define LINQ to SharePoint queries that perform data operations against the SharePoint lists. The classes were generated automatically by the SPMetal command-line tool.

The following diagram shows the structure of the DataModels.SharePointList.PartsMgmnt project in Solution Explorer.

The DataModels.SharePointList.PartsMgmnt Project


The key components of this project are as follows:

  • The Images node is a SharePoint mapped folder that deploys the banner image used on the custom user interface pages within the solution.
  • The project includes several feature manifest nodes that deploy individual Visual Web Parts. Each Visual Web Part provides a custom user interface that allows you to interact with a particular part of the data model.
  • The Pages node contains the feature manifest for a single Web Part page, PartsMgmnt.aspx, which defines the page layout for our custom user interface pages. The accompanying Elements.xml file includes multiple File elements for this page, all with different Web Part-based content for the page. These elements define the pages that you see when you browse the deployed reference implementation.
  • The PartsMgmntNavigation node contains a feature manifest that adds navigation links for each custom user interface page to the Quick Launch bar on the left-hand navigation panel.
  • The ViewModels node contains ViewModel classes that represent views of the entities in the data model. For example, the PartInventoryViewModel class represents a data view that contains fields from the Parts content type and the InventoryLocations content type.
  • The PartManagementRepository class is a central repository that contains all the LINQ to SharePoint-based data operations that are used within the project. This class implements an interface, IPartManagementRepository, which enables us to use service location to replace the repository class with a fake implementation for the purposes of unit testing.

In the remainder of this documentation, we will take a closer look at the key points of interest in these components.