What is the proper way to pass an answer (a collection) back to Silverlight?
For example, if I have a service application that sits on top of the Northwind sample database and the service has a method called GetEmployees(). What is the proper ‘thing’ to pass back to Silverlight? An IQueryable ?
Then considering the Async/Result casting stuff on the Silverlight side what do I cast it too? An IQueryable ?
UPDATE:
Is it the declaration of [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] that allows a remote client to see the structs (entities) from a service?? I didn’t know there was such thing as a Silverlight-friendly-WCF class so thats not what I started with. Once I added that attribute in the solution wouldn’t let me use the service any more without it. So I could not test what I was seeing before. Any thoughts on what AspNetCompatibilityRequirementsMode.Allowed does under the hood?
UPDATE 2:
See comments to Terry Donaghe.
Did you just try passing arrays of base types around? Unless you create DataContracts, WCF doesn’t know what any of your objects are. When you try to pass a List WCF really just passes an array since it’s designed to try to be inter-operable.
Define a DataContract to contain information about the Employees (or whatever). Try to keep it relatively simple. When you create your proxy (probably with svcutil or Add Service Reference) VS2008 will auto-magically define the DataContracts on your client side and then you can use them just like a regular object.
I prefer to use WCF manually – I create my own contract, implementation and proxy dlls. Doing that gives me a great deal of flexibility as far as de-serialization and other stuff is concerned. For more on that, see these two references:
WCF the Manual Way, the Right Way
Manual WCF – an Extension
Also, please see Chapter 3 of the WCF Bible, ‘Programming WCF Services’ by Juval Lowy. It’s chock full of info on DataContracts.