Likes

Developing Windows Azure and Web Services Lab @ 6 Ans 1

OData is a data access protocol that provides standard CRUD access of a data source via a website. To add support for OData protocol you will install a NuGet Microsoft.AspNet.WebApi.OData package, and then decorate the methods that you want to support OData with [Queryable] attribute.
The main tasks for this exercise are:
1. Add a queryable action to the flight schedule service.
2. Handle the search event in the client application and query the flight schedule service by using OData filters.




Task 1: Adding a queryable action to the flight schedule service
To add a queryable action to the flight schedule service, you need to perform the following steps:
1. Browse to the location where the Exercise 03.zip file is saved.
2. Extract the files.
3. Press the Windows logo key. The Start screen is displayed.
4. Start typing Visual Studio 2012. The Search pane and Apps screen are displayed.
5. Right-click the Visual Studio 2012 tile, and then select Run as Administrator.
6. Select FILE—Open—Project-Solution. The Open Project dialog box is displayed.
7. Browse to the location where the Exercise 03 folder is extracted.
8. Double-click the Exercise 03 folder.
9. Double-click the BlueYonder.Companion folder.
10. Select the BlueYonder.Companion.sin file.
11. Click the Open button. The BlueYonder.Companion - Microsoft Visual Studio window is displayed.
12. Ensure that the Solution Explorer window is opened.
13. Click the TOOL S menu on the toolbar, and then select Library Package Manager—Package Manager Console. The Package Manager Console window is displayed.
14. Type install-package Microsoft.AspNet.WebApi.OData -version 0.1.0-alpha-120815 -ProjectName BlueYonder.Companion.Controllers, and then press the Enter key.
15. Wait until Package Manager Console finished downloading and adding the package.
16. Ensure that the Solution Explorer window is opened.
17. Expand the BlueYonder.Companion.Controllers node.
18. Double-click the LocationsController.es file. The LocationsController.es file is displayed.
19. Replace the existing Get? {) method, which has the three parameters with the following code snippet in the LocationsController.es file:
[Queryable]
public IQueryable<Location> Get()
{
return Locations.GetAll();
}
20. Select FILE—Save All to save the changes.
21. Close Microsoft Visual Studio 2012.
Task 2: Handling the Search Event in the Client Application and Query the Flight Schedule Service by Using OData filters
To handle the search event in the client application and query the flight schedule service by Using OData filters, you need to perform the following steps:
1. Press the Windows logo key. The Start screen is displayed.
2. Start hyping Visual Studio 2012. The Search pane and Apps screen are displayed.
3. Right-click the Visual Studio 2012 tile, and then select Run as Administrator.
4. Select FILE—Open—Projecb'Solution. The Open Project dialog box is displayed.
5. Browse to the location where the Exercise 03 folder is extracted.
6. Double-click the Exercise 03 folder.
7. Double-click the BlueYonder.Companion.Client folder.
8. Select the BlueYonder.Companion.Client.sln file.
9. Click the Open button. The BlueYonder.Companion.Client - Microsoft Visual Studio window is displayed.
10. Ensure that Solution Explorer window is opened.
11. Expand the BlueYonder.Comapanion.Shared node.
12. Double-click the Addresses.es file. The Addresses.es file is displayed.
13. Replace the return statement of the GetLocationsWithQueryUri property with the following code snippet:
return GetLocationsUri + M?Sfilter=substringof(tolower(,{0},),tolower(City))";
14. Select FILE— Save All to save the changes.
15. Close Microsoft Visual Studio 2012.

No comments: