Home > Articles > Programming > Visual Studio

  • Print
  • + Share This
From the author of Creating a Sample Application

Creating a Sample Application

In Visual Studio 2010, create a Windows Phone project. I'm using Visual Basic as the programming language for this example, but the steps are the same for Visual C#:

  1. Select the Windows Phone Application template and specify MobileOrdersClient as the project name, as shown in Figure 4.
  2. The selected project template is the most basic; it doesn't include sample data or a prebuilt user interface, so we can add our logic without wasting time having to remove or change unused objects.

    Figure 4 Creating a Windows Phone project.

  3. When you click OK, Visual Studio will ask which version of Windows Phone the project must target; select Windows Phone 7.1.
  4. Remember that Windows Phone 7.1 is the version of the SDK, but it actually targets version 7.5 of the operating system (also known as Mango). In other words, if you select the Windows Phone 7.1 developer tools, your app will run on Windows Phone 7.5.

  5. After creating the project, add a reference to the OData service by selecting Project > Add Service Reference.
  6. In the Add Service Reference dialog, specify the URL of the service for the desired data source. (In this case, the service reference will point to the LightSwitch intrinsic data.) Click Go.
  7. Visual Studio requests your administrator credentials to download the service information. Enter the username and password for the LightSwitch application administrator that you specified in the Publish Application Wizard when publishing the application to the web server (see Figure 5).
  8. Figure 5 Specifying administrator credentials for connecting to the OData service.

  9. Visual Studio displays the list of entity sets exposed by the OData service, in this case Customers and Orders (see Figure 6). The service namespace is ServiceReference1. Change it to OrdersServiceReference and click OK.
  10. Visual Studio generates a proxy class required for connecting to the service in .NET code, as well as two business classes representing customers and orders.

    There's nothing else to do to reference an OData service. The rest of the required tasks will be performed later in code (such as connecting to the service and working with data).

    Figure 6 Visual Studio shows entity sets available in the OData service.

  • + Share This
  • 🔖 Save To Your Account