Silverlight, Web Services and Datasets
I sat down today to learn about using Silverlight and Dataset from a Web Service. Something you’d think would be rather trivial.
I mean, seriously folks. We use Datasets as a means of transporting data up and down the tiers of just about everything we do in .NET. It would stand to reason that using DataSets as our transport mechanism in Silverlight would be a given.
But no. We have to jump through all kinds of hoops.
In fact, if you try to return a DataSet or a DataTable you won’t get any data. If you try to return a DataRow, you’ll get an error.
Instead you have to stick with certain classes or decorate your own class with some attributes.
So let me get this straight. If I want to return several records from a table back to my Silverlight application, I have to:
- Create a new class with properties that map to my table.
- Decorate that class with the appropriate attributes so that it will get serialized back to Silverlight correctly.
- Do my own database access
- Create the new “Row Objects” with my class and add them to a collection
- Return the collection from my web method to my Silverlight application
Um, isn’t that what Datasets were created for? Am I missing something? Somebody, PLEASE tell me I’m missing something!
Other post in Silverlight
- Installing Silverlight2 Tools for Visual Studio - December 31st, 2008
- More on SilverLight Developer Installation - January 7th, 2009
- SilverLight - Layout Managers - January 14th, 2009
- Friday Books - Silverlight 2 in Action - January 16th, 2009
- Review of the MDC at NYC - January 21st, 2009
- Silverlight - Wire up your form for programming - February 4th, 2009
- JavaScript vs Silverlight vs ... - February 10th, 2009
- Silverlight - Databinding - February 17th, 2009
- Friday Books - Data-Driven Services with SL2 - February 20th, 2009
- Silverlight - Databinding ListBox - March 5th, 2009
- Friday Books - Silverlight 2 Recipes - March 13th, 2009
- Silverlight - Binding ResourceDictionaries - March 17th, 2009
- Silverlight - RESX Files and Internationalization - April 2nd, 2009
- Friday Books - Introducing MS Silverlight 2 - April 3rd, 2009
- Silverlight, Web Services and Datasets - April 23rd, 2009
- Silverlight – Databinding to a Web Service - April 27th, 2009
- Silverlight – Navigating Data - May 7th, 2009
- Essential Silverlight 3 - October 30th, 2009
- Do you Need My Help? - November 18th, 2009
Other Related Items:
Silverlight Essential TrainingMike Harsh is the program manager on the Silverlig
Expression Studio 4 Ultimate Microsoft Expression Studio 4 Ultimate opens up a new world of creative possibility. Its professional design tools give you the freedom to make you... Read More >
2007 New Models -#16 '70 Pontiac Firebird SilverLight Blue Roof Tampo K-Mart Exclusive #2007-16 Collectible Collector Car Mattel Hot Wheels2007 New Models -#16 '70 Pontiac Firebird SilverLight Blue Roof Tampo K-Mart Exclusive #2007-16 Collectible Collector Car Mattel Hot Wheels










Firstly, imo exposing .NET DataSets over services is generally a bad idea, esp when those services are being consumed by non-.NET clients (which true services are meant to cater for)
as for why they haven’t included the DataSet in Silverlight, you’d have to ask the guys at Microsoft. (I can’t say that I miss them all that much – well defined objects are way better for Binding, business logic etc.)
For a fairly good work-around – check out this post:
http://silverlight.net/forums/p/16733/63248.aspx
I have the same question.
Linq is not a solution for n-tier. ADO.NET through WCF is a possibility but what if you don’t want to simply transfer your database front end to the client. What if stored procedures are required.
DataSet and especially Typed ones are the easiest and quickest way to transfer organized and related data over the wire.
Why have they put aside this great mechanism?
Jax,
We are going to have to agree to disagree. Specifically about “well defined object are way better for Binding…”
There are specific features of databinding that you lose when you don’t use datasets.
I having a similar problem with accessing stored procedures in our database, that returns data from a cross-join, with X number of columns.
When I go to show the ado data service in the browser, I get a Request Error – The server encountered an error processing the request. See server logs for more details.
What’s a good approch for dealing with this type of dynamic data?
Thanks for you help,
Look in the event logs (event viewer) chances are there is an error about the time you did this that will tell you exactly what the problem is.