Udostępnij za pośrednictwem


Reference Implementation: SharePoint List Data Models

Microsoft® SharePoint® 2010 introduces new functionality that makes it easier to implement real-world data models using SharePoint lists. In particular, the ability to build relationships between SharePoint lists and the ability to impose behavioral constraints on these relationships, such as cascading deletions and restricting deletions, brings the capabilities of SharePoint lists closer to those of a relational database and boosts the credentials of SharePoint as a platform for data-driven applications. The introduction of the LINQ to SharePoint provider makes it easier to query data in SharePoint lists without constructing complex Collaborative Application Markup Language (CAML) queries. The SharePoint List Data Models reference implementation demonstrates how you can use these new features to implement a relatively complex data model on the SharePoint platform, and how you can use that data model to power a fairly sophisticated data-driven application.

The implementation highlights techniques and best practices in the following areas:

  • Using SharePoint lists to implement a data model.
  • Modeling many-to-many relationships with SharePoint lists.
  • Building entity classes for use with the LINQ to SharePoint provider.
  • Using LINQ expressions to query SharePoint lists.
  • Using ViewModel classes with LINQ to SharePoint in order to simplify user interface logic.

Solution Scenario

In this example, suppose you are providing consultancy services to a pharmaceutical company named Contoso Inc. Contoso has production plants in several locations that operate an extensive range of manufacturing machinery. Every machine requires parts to be replaced on a regular basis due to wear and tear in the course of everyday operations. Different types of machines consume a wide variety of parts, which means the manufacturing team at Contoso must manage large amounts of information relating to machines, parts, and suppliers.

Currently, the Springfield production plant uses a desktop application built on FoxPro to track part inventories for machine maintenance and repair. This application is used by the warehouse manager to track how many parts are in inventory and where the parts are located. The data model for the parts management system is relatively complex, and includes one-to-many relationships, many-to-many relationships, and foreign key constraints that restrict the deletion of rows that have dependencies in other tables. Whenever employees need a spare part for maintenance or repair, they must contact the warehouse manager to see if the part is available, slowing down both the warehouse manager and the employees. The user interface for the current parts management system allows the warehouse manager to search for items using wildcard filters, and allows him to create, update, and delete items. The user can also browse associated data; for example, users can browse the parts associated with a specified machine.

Imagine now that as part of an infrastructure consolidation and employee efficiency exercise, the Contoso manufacturing team wants you to migrate this functionality to the Contoso SharePoint 2010 intranet portal. To accomplish this, you create a SharePoint solution that implements the part management data model using SharePoint lists. The solution includes several custom Web Parts and Web Part pages that allow employees to create, retrieve, update, delete, and query entities in the parts management system from a centrally managed site.

Deploying the SharePoint List Data Models RI

The SharePoint List Data Models RI includes an automated installation script that creates various site collections, deploys the RI components, and adds sample data. After running the installation script, browse to the new SharePointList site collection at http://<Hostname>/sites/sharepointlist. You can open and run the project in Visual Studio, but this does not create a site collection or add sample data. To see the system fully functioning, you must run the installation script. The following table summarizes how to get started with the SharePoint List Data Models RI.

Question

Answer

Where can I find the Workflow Activities RI?

<install location>\Source\DataModels\DataModels.SharePointList

What is the name of the solution file?

DataModels.SharePointList.sln

What are the system requirements?

SharePoint Foundation 2010

What preconditions are required for installation?

  • You must be a member of SharePoint Farm Admin.
  • You must be a member of the Windows admin group.
  • SharePoint must be installed at http://<Hostname:80>. If you want to install to a different location, you can edit these settings in the Settings.xml file located in the Setup directory for the solution.
  • SharePoint 2010 Administration service must be running. By default, this service is set to a manual start. To start the service, click Start on the taskbar, point to Administrative Tools, click Services, double-click SharePoint 2010 Administration service, and then click Start.

How Do I Install the SharePoint List Data Models RI?

Follow the instructions in the readme file located in the project folder.

What is the default installation location?

http://<Hostname>/sites/ SharePointList

(This location can be altered by changing the Settings.xml file in the Setup directory.)

How do I download the SharePoint List Data Models RI?

The SharePoint List Data Models RI is included in the download Developing Applications for SharePoint 2010.