Walkthrough: Manually Accessing and Changing Data (WCF Data Services/Silverlight)


This walkthrough shows how to access data from the Northwind data service and display this data in an application for Silverlight. The Northwind data service is created when you complete the steps in the topic How to: Create the Northwind Data Service (WCF Data Services/Silverlight).

This walkthrough demonstrates manual data binding, which requires you to handle the events raised by the ObservableCollection<T> used for binding and call the appropriate methods on DataServiceContext that represent these changes. WCF Data Services also supports automatic data binding by using the DataServiceCollection<T> class. For more information, see How to: Bind Data Service Data to Controls (WCF Data Services/Silverlight).

Topics in this section form a walkthrough, and each topic builds on the previous one. At the end of each topic, you will have a functional application. The complete sample application can be downloaded from the MSDN Code Gallery Web site.

The first task shows how to define the Silverlight-based application. In subsequent tasks, you will create and execute queries against the data service that return entity data as objects; bind entity data to controls; and insert, update, and delete data by using the data service.

Note Note:

All operations against a data service from a Silverlight-based application are executed asynchronously.

This walkthrough is intended for users who are familiar with developing applications for Silverlight by using Visual Studio, but who are new to WCF Data Services. To complete the walkthrough, you must have the following installed: 

For more information, see Silverlight Tools.

Creating the Client Application

Create the application and generate client libraries that are based on the Northwind data service by using the Add Service Reference tool.

Querying the Data Service

Query the Northwind data service for Customers and Orders and bind query results to controls.

Loading Related Entities

Load Order_Details objects that are related to select Orders objects.

Modifying and Deleting Entity Data

Change or delete select Order_Details entities by using the data service.

Creating New Entities with Relationships

Create new Order_Details objects that are related to an Order object and persist them as new entities and relationships in the data service.