OData Tool Spotlight is a series in which I try to explore tools which make it easy to work with OData Service and feeds. You can read my previous articles on this series in my blog. Here is the previous article links:
In this article, we will look at one more useful tool known as "OData Explorer". So lets take a lap around OData Explorer.
What is OData Explorer ?
OData Explorer is tool from Microsoft ADO.NET Data Services or now named as WCF Data Services Team. Here is the official statement of what is OData Explorer?
A Silverlight application that can be installed in-browser and out of browser , and allows you to perform ad-hoc and guided queries across a given OData Service
Here is the official blog post announcing the OData Explorer: http://blogs.msdn.com/b/phaniraj/archive/2010/03/17/announcing-the-odata-explorer.aspx
Now lets start looking at the features of OData Explorer
Accessing OData Explorer:
To access the Silverlight OData Explorer, head over to http://www.silverlight.net/ODataExplorer. This is a Silverlight based application. So your system needs to have the Silverlight Runtime installed. This is both in-browser as well as out-of browser Silverlight application i.e. this can be accessed in the browser as well as can be installed as a desktop application.
OData Explorer Layout :
First lets familiarize ourselves with the layout of OData Explorer. It comprises of 4 Panes:
- OData Services Pane – Lists all the Services you are connected to. OData Explorer allows you to work with more than one Service within the tool.
- Odata Service Collections Pane – Lists all the collections that the OData Service exposes.
- Odata Service Query Pane – Allows you to write OData queries against the selected service.
- Results Pane – As the name suggests, this pane displays the data.
We will go through each of these panes in detail in coming sections. Here is the screen shot of the same:
Connecting to OData Services:
If you visit OData Explorer for the first time in any session, you will be presented with "Add New OData Service" dialog. You will use this dialog whenever you want to add a new service to work with. Here is the screen shot of the same:
You provide a friendly name for your service – so that it is easy to read in the Services Pane. You will provide the OData Service Root URI. Clicking Ok will connect to the OData Service and add it to your Services Pane. Here is a example of connecting to EBay OData Service:
It also has a feature of listing out Public OData Services. If you click the button "Browse Public OData Services", it will list out all the OData Public Services as seen on OData.org site. If you select any one – the URI will be automatically filled up. Here is the screen shot:
After selecting a service from the list, it will take you to Add New OData Service and you click on Ok to connect to the selected OData Service.
OData Services Pane:
Services Pane is a region within the tool which will display the different OData Service you have connected to. At any point of time you can inly work with 1 OData Service. But you can be connected to more than 1 OData Service. Here is a screen shot of my Services Pane:
As you can see I have added many OData Services and they are all displayed with a friendly name in the Services Pane. Services Pane has 3 buttons. They are:
Add New – Used to add a new odata service to your session.
Delete – Used to delete a odata service from services pane.
PowerPivot – Used to save the OData Service Document as a ATOM Service Document.
OData Service Collection Pane:
This pane displays all the collection that a OData Service exposes. For e.g. I have added ebay odata service and when selected in the services pane, displays the collection that ebay exposes. Here is the screenshot of the same:
Clicking on any collection will execute that query and load the data in the results pane.
OData Service Query Pane:
When you click on a collection, the query pane will automatically show the query behind the collection. For e.g. I have added OData Service from Pluralsight. When I select the collection Courses from collection pane, here is what the query pane will look like:
As soon as you select a Collection, query is executed and results are shown in the results pane. You can also construct query filters using the "Build Query" option. Lets see an example. I want to list all courses which talk about "patterns". So I want to build the query something like – Return all course where:
- Column "Name" contains word "pattern" AND
Column "ShortDescription" contains word "pattern"
Here is how the query builder can be used to build that query:
First select the column "Name", then select "Contains", then enter the word "Pattern" and click Add Query option
Second, select column "ShortDescription", then select "Contains", then enter word "pattern" and click Add Query Option.
When above steps have been performed click Ok. The query pane will look like below:
Clicking "Go" will execute the query and show the results.
The results pane, as the name goes will display the results of any query execution. When you select a collection the query gets executed and the results pane nicely shows a loading message. Here is the screenshot of the same:
Clicking Cancel will abort the data retrieval.
Results can be displayed in 2 Modes. They are
- Grid Mode – Data is presented in a tabular format
- Raw Mode – Data is displayed in its native format i.e. XML
This is the default mode in which the data gets displayed. Lets take an example of Northwind Service and look at the screenshot below:
As you can see the data is neatly displayed in a grid with all columns selected by default. The "Show Navigation Properties" checkbox controls whether the navigation property columns needs to be shown or not. In the above screen shot – since the show navigation property is checked we can see the columns "Category", "Order_Details" and "Supplier" column. You can control what columns to see by using the "Select Columns" drop down.
As the name says, the data is retrieved in its RAW format i.e. in most cases ATOM XML format. Lets see an example of retrieving Products collection from Northwind service in its RAW format:
The data can also be viewed in JSON format. Select the data format as JSON and hit Go. Here is the response:
So we saw all the features that this tool supports. It also has the capability to be installed as a Out-Of browser application. Look out for Install button on right hand top corner. Once installed you can use this tool as a desktop application.
This tool is certainly of the earliest tool which was released to support OData. I think the vision was to make it like a Universal OData Browser. But after going through the features and having looked at LINQPad and Sesame Data Browser, I would recommend using LINQPad or Sesame Data Browser in place of this tool. This also has its SDK available for download, if you would like to understand how this is built. Here is the URL: odata-sdk – under "OData SDK – Sample Code" section.
Till next time, Happy Coding. Code with Passion, Decode with Patience.