Some basic steps to consume data
Step 1 |
Start Visual Studio and open the starter project |
Step 2 |
Add a service reference to the data |
Step 3 |
Add using statements |
Step 4 |
Add the Account Key to your code so you can access the data |
Step 5 |
Create a LINQ query to get to the data |
Step 6 |
Run the code and see the results displayed |
At a high level, here are the changes we will need to make: Here is the class we added:
Service Reference for UN Gender Data |
https://api.datamarket.azure.com/Data.ashx/UnitedNations/GenderInfo2007/ |
Service Reference Name |
UNData |
Using Statements to add |
using System.Net; using ConsumingDataMarketData; |
Here are the results:
Intellisense is available – notice that as soon as we hit the period (.) we get information about our data source, making the coding less error-prone.
It is very easy to consume DataMarket data. It is in atom pub format. Also notice that we did not need to worry about putting the OData syntax. Just execute the LINQ query and the tooling takes care of the rest. |