Home  >  

Silverlight and ADO.NET Data Services

Author photo
| | Comments (3)
AddThis Social Bookmark Button

SIlverlight 2 allows you to talk to RESTful services as well as SOAP based services. You can pass/consume XML or JSON with these web services too. All stuff we would expect at some pointto expose a basic domain entity model for business applications. Microsoft also has a technology called ADO.NET Data Services (codenamed Astoria). I still like the Astoria nickname as its easier to say and in my opinion the title "ADO.NET Data Services" implies a heavy connection to a data layer. While there is some truth to that, the reality is that Astoria simply exposes a domain entity model through a RESTful model over HTTP. The model could have nothing to do with ADO.NET. In fact the model could be any entity model written in .NET code as long as it exposed IQueryable. This means that a standard class library in .NET code can be exposed through a RESTful set of web services over HTTP using Astoria very easily.

The beauty of Astoria is that it exposes the model without having to write dozens or hundreds of service methods to do so. Instead, it exposes the model thorugh a series of unique URI's that are mapped to the domain entities. For example http://mydomain/myservice.svc/customer(101)/orders?orderby=orderdate could return a list of orders for the customer with an ID = 101 sorted by order date. The data can be returned as XML or JSON, too. No service is written on the server side to handle this specific action, instead Astoria handles the mapping to the entities and offers a set of operators such as orderby and filter that can massage the data. Its a pretty slick concept overall, especially for those who love REST. The advantage here is that you don;t have to write a lot of RESTful web service methods to do this, since Astoria does that work for you iunder the covers.

Calling Astoria ... this can be done through any HTTP web request by passing a URI. Or, if you use Silverlight 2, you can use the Silverlight client library for Astoria which allows you to write a LINQ query to operate on the entities using the LINQ query syntax. the query is examined by the client library and turned into the URI / HTTP request. So in the end it works the same. The client library just allows a developer to make a simple request using the well known LINQ syntax if available.If you don;t want to use LINQ, you can still make a standard HTTP web request, too. There are lots of options, which is always good!

Read more from John Papa. John Papa's Atom feed John_Papa on Twitter

Comments

3 Comments

It is not so ease to learn how ADO.NET Data Services works together with Silverlight but it is a great experience. Do it!

Frank said:

I am having a difficult time with Silverlight ADO ..
The latest question is when I try to add a table to the datamodel and then update the service reference, I get a error message saying the server, local host etc etc etc refuses ..

any thoughts?

John Papa said:

Where you able to add the service ref in the first place and compile it and run it OK? If so, then try removing the service ref and re-add it. If you could never get it to work, make sure the service runs on the same domain as the silverlight client's web host. ADO.NET Data Services only works on the same domain right now ... no cross domain capabilities yet (for a variety of reasons they are working out). For example, if your service is on http://localhost:1234 and your web site hosting silverlight is on http://localhost:6789, it will not work. They both need to be on the same domain.

Leave a comment


Tag Cloud

Question of the Week: Dream App

If you had an unlimited budget and unlimited resources what application would you build and why would you build it?

Answer

Latest Features

Recommended for You

@InsideRIA on Twitter

Archives

  • Or, visit our complete archive.  

About This Site

Welcome to the premiere community site for all things RIA sponsored by O'Reilly Media and Adobe Systems Incorporated.