Home > Articles > Mobile Application Development & Programming

  • Print
  • + Share This
From the author of Adding a Reference to LightSwitch's OData Service

Adding a Reference to LightSwitch's OData Service

In Solution Explorer, right-click the project name and select Add Service Reference. You've already used the Add Service Reference dialog several times in previous articles in this series, so I assume that you're familiar with it by this point. In the dialog, you need to specify the URL for the desired data source—in this case, the LightSwitch intrinsic data. The URL has the following form:


In the current example, the server name is the local Internet Information Services name (LocalHost) and the application name is ExposingOData, so the URL is as follows:


However, because the device emulator for Windows Phone 8 has a different behavior over networks, you need to specify the IP address for the server, instead of its name.

When you click Go, Visual Studio 2012 will ask you to enter credentials to download the service information (see Figure 4). Here you have to enter credentials for the LightSwitch application administrator that you specified in the Publish Wizard when publishing the application to the web server.

Figure 4 Entering administrator credentials to access the OData service.

At this point, Visual Studio displays the list of entity sets exposed by the OData service, in this case Customers and Orders. The default service namespace is ServiceReference1, but you can change it to OrdersServiceReference for consistency. Figure 5 shows how the dialog looks (notice the IP address used to reach the server).

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

When you click OK, 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. This is possible because of the OData Client Tools for Windows Phone installed previously. Now that you've completed the steps required to add a reference to LightSwitch's OData service, it's time to design the user interface of the sample mobile application.

  • + Share This
  • 🔖 Save To Your Account