Skip to main content

Cloud

ADO.NET Data Services & Querying Using URIs

I have been playing with ADO.NET Data Services framework recently in its preview state and am excited about this new upcoming technology with what it has to offer! This new framework really facilitates the surfacing of server side data. Its appealing aspect resides in the fact that it is reaching for server side resources using HTTP and the underlying verb of HTTP such as GET, POST or DELETE. The surfacing of the data is done using REST web services which use URIs to identify results on the server and use HTTP verb to describe what we want to do with those results. We can get back the data from the services in the Atom Syndication format (web feeds XML language) or in the Javascript Object Notifaciton (JSON). As far as data sources, Data Services can quickly and efficiently surface pretty much any kind of data such as Entity Framework data, LINQ to SQL data or some arbitrary data.

One of the attracting aspect of Data Services is the simplicity in the way they access server data is being surfaced using URIs. Here is some examples of what can be accomplished using those URIs. Let’s assume we have created a Data Service "dataservice.svc" that surface our data, in this case a bike catalog.

http://server/dataservice.svc/Bikes – this URI points to the Entity set Bikes and returns a list of bikes

http://server/dataservice.svc/Bikes(‘MB123523’) – using the primary key ‘ID’ now a single entity is targeted, the bike with the ID of ‘MB123523’ is returned

http://server/dataservice.svc/Bikes(‘MB123523’)/Price – properties within a bike entity can be retrieved as well, here the price property is returned for the bike with the ID of ‘MB123523’

http://server/dataservice.svc/Bikes(‘MB123523’)/Orders – here, a set of orders entities associated with the bike of ID ‘MB123523’ entity is returned

http://server/dataservice.svc/Bikes?$expand=Orders – this URI will return bikes and the orders of the bikes

http://server/dataservice.svc/Bikes?$expand=Orders,Price – this will return the bikes, the orders and the price of the bikes

http://server/dataservice.svc/Bikes?$expand=Orders,Orders/Date,Price – this will return the bikes, the orders, the date of the orders of the bikes, the price of the bikes

http://server/dataservice.svc/Bikes(‘MB123523’)/Orders?$filter=Completed eq true – you can use the $filter operator as well to define a more defined set of entities

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

PointBridge Blogs

More from this Author

Follow Us
TwitterLinkedinFacebookYoutubeInstagram