Share via


Exercise 2: Using the SharePoint Client Object Model to generate sample data

In this exercise, you will use the SharePoint Client Object Model to generate sample data from the Parts list. The sample data will be used by Expression Blend in Exercise 3.

Task 1 – Generating Sample Data

In this task, you will generate sample data from the Parts list.

  1. In the <INSTALL>\Labs\UsingSampleDataWithExpressionBlend\Source\Begin folder, double-click the SP.Blend.Sample.Data.Generator.sln Visual Studio 2010 solution file to open it.
  2. Once the Solution is loaded, in the Solution Explorer, right-click MainWindow.xaml and select View Code.
  3. Inspect the code in the generateSampleDataButton_Click method to see how the SharePoint Client Object Model queries the Parts list and creates an XML file that represents the list items, columns for each list item, and values for each column.
  4. Press F5 to run the program.
  5. When the program is loaded, click Generate Sample Data.

    Figure 5

    SharePoint Expression Blend Sample Data Generator

  6. When the sample data is generated the application displays a message that indicates it is finished, as seen in the screenshot below.

    Figure 6

    SharePoint Expression Blend Sample Data Generator – Sample File Saved

  7. Open the c:\SPBlendSampleData.xml file in Visual Studio.
  8. Notice the XML generated by the application.

    Figure 7

    XML generated

Exercise 2 Verification

In order to verify that you have correctly performed all steps of exercise 2, proceed as follows:

Verification 1

In this verification, you will open the c:\SPBlendSampleData.xml file in Visual Studio to validate it contains the sample data.

Open the c:\SPBlendSampleData.xml file in Visual Studio.

  1. Validate the file contains XML sample data as seen in the screenshot below.

    Figure 8

    XML generated