Share via


Lab 08: Using WCF RIA Services

Silverlight provides a flexible framework for working with distributed data retrieved from different types of services but does require developers to understand asynchronous programming and handle callback operations. Applications that allow users to update, insert and delete data also require developers to perform their own client-side object tracking and to write client and server-side code to validate data. While each of these tasks can be addressed with different coding techniques, using a framework that simplifies these types of tasks can lead to greater overall productivity and fewer bugs.

WCF RIA Services provides a distributed data exchange framework that builds upon existing functionality in Windows Communication Foundation (WCF) to allow data to be exchanged between a Silverlight client and a server. It provides developers with a simplified way to work with the asynchronous programming model, track object state within Silverlight applications, share validation code between client and server projects, build client-side proxy objects, plus more.

In this lab you'll create a WCF RIA Services domain service class and call it from a Silverlight application. You'll also learn how data annotations can be applied to metadata classes to validate object properties and share validation logic across client and server. A bonus exercise is also included to show how WCF RIA Services can be used with custom patterns such as the repository pattern. The application that you'll work with in the lab exercises is shown next:

Figure 1

Customer Orders Application

You Will Benefit from this Lab if:

  • You're interested in building Silverlight applications that take advantage of WCF RIA Services
  • You're interested in learning how to create a domain service and call it from a Silverlight client
  • You want to share validation logic between a client and a server

You Will Learn:

  • How to create an Entity Framework 4 model
  • How to create a WCF RIA Services domain service using the built-in Visual Studio 2010 wizard
  • How to customize domain service methods
  • How to call a domain service from a Silverlight client
  • How to share validation logic between the client and server

Business Requirements for the Silverlight application include:

  • Create a new Silverlight Business Application
  • Create a new Entity Framework 4 Model
  • Create a WCF RIA Services domain service class
  • Customize domain service class methods
  • Build a user interface
  • Add code to call the domain service using the generated domain context class
  • Add code to send updates from the Silverlight client to the domain service
  • Create a custom data validation class
  • Add data validation attributes to validate data and share the validation logic between the service and Silverlight client projects

Estimated Time: 45 minutes