Step 2: Create a Cache Subscription

SharePoint 2010

Last modified: July 06, 2010

Applies to: SharePoint Server 2010

A cache subscription file defines which external content types in the BDC model to cache and which queries in the model to use to populate the data in the cache. The subscription file also defines how frequently to refresh external items in the cache. It is represented as an XML file whose name ends with Subscription.xml and is automatically generated by Microsoft Business Connectivity Services (BCS) during deployment of a simple solution. For an advanced code-based solution, you must create the Subscription.xml file manually. Although it follows a very simple schema and is not difficult to create, the SDK provides a template for you that you can use to create a subscription file quickly.

In this scenario, create a subscription file for the Customer external content type.

Note Note

Because the AdventureWorks sample database contains more than 2,000 customers, the sample web service brings back only the top 1,000 customer rows to keep the amount of data coming into the client small and manageable. Therefore, in this scenario, the related orders for only these 1,000 customers are returned, and not the entire list of orders. This is why we define a subscription association in this sample—to populate the cache with the related orders of the 1,000 customers. You can also consider using a BulkAssociationNavigator method instance to improve performance.

Use one of the following two approaches to create cache subscriptions.

Tooling Approach

Use the BCS Artifact Generator Tool to create the required subscription files based on the BDC model.

Manual Approach

  1. Locate the Template: SubscriptionWithAssociation_Subscription.xml file that is provided in the SharePoint 2010 SDK, copy it, and then save it in the Solution Artifacts folder as CustomerSubscription.xml.

  2. Open CustomerSubscription.xml for editing in an XML editor. If you are opening the XML file in Microsoft Visual Studio, attach the Subscription schema (Subscription.xsd). This gives you IntelliSense functionality and prevents you from creating entries that are not valid.

  3. Replace the values marked with EnterX in the XML with valid values. The following XML example shows how the file might look after editing.

    Note Note

    This is a very simple subscription. You can create more complex subscription files by adding more elements and properties to the file. See the Subscription Schema documentation for more information.

    <?xml version="1.0" encoding="utf-8"?>
    <Subscription LobSystemInstanceName="AdventureWorksContosoLOBInstance" 
    EntityNamespace="AdventureWorksContoso" EntityName="Customer" 
    Name="AdventureWorksContosoCustomerSubscription" View="GetCustomerById" IsCached="true" 
    RefreshIntervalInMinutes="360" xmlns="">
        <Query Name="AdventureWorksContosoCustomerQuery" MethodInstanceName="GetCustomers" 
    DefaultDisplayName="Customer Read List" RefreshIntervalInMinutes="180" IsCached="true" Enabled="true" />
  4. Save and close the file.

You have successfully created the cache subscription that you need for the advanced code-based Outlook solution.