Book Image

Windows Phone 7.5 Data Cookbook

By : Ramesh Thalli
Book Image

Windows Phone 7.5 Data Cookbook

By: Ramesh Thalli

Overview of this book

Windows Phone 7.5 Mango contains support for apps written in Silverlight or XNA. These apps can store data on the device, and also load and manipulate data from "the cloud" and other web services.This Windows Phone 7.5 Data Cookbook has a range of recipes to help you apply data handling concepts. You will be able to apply the knowledge gained from these recipes to build your own apps effectively. This Windows Phone 7.5 Data Cookbook starts with data binding concepts at the UI layer and then shows different ways of saving data locally and externally in databases. The book ends with a look at the popular MVVM software design pattern. The recipes contained in this book will make you an expert in the areas of data access and storage.
Table of Contents (15 chapters)
Windows Phone 7.5 Data Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Building a service layer using WCF


In the last recipe, we learned how to call a simple WCF service from the client application. In this recipe let's create a MyTasks Service.

Getting ready

Create a new project using the WCF service template and follow the same steps as in the recipe Writing and consuming a simple web service to create the service.

How to do it...

In this recipe, we will first create the WCF service and then build the Data Contract and Service Contract. In the Data Contract, we will add all the Data members; in the Service Contract we will return a collection class. Once the service is built successfully, we create the Phone Client application to call the service when searching for a task name.

  1. Right-click on the project and click on Add new item. Select the WCF service template and name it MyTaskService.svc.

  2. Open the IMyTaskService.cs file and add the following code for class MyTask and IMyTaskService:

    namespace Recipe2_MyTasksService
    {
      [DataContract]
      public class MyTask...