views:

3272

answers:

4

I have an interesting problem: I can get results back from my WCF service to my Silverlight code as a DataTable. Problem is, Silverlight doesn't support DataTable objects. I've been poking around with what I can do, and the best I can come up with is passing it back as a List.

Great, right? Nope. Now I'm getting the same problem as before; nothing get returned. Code shows it as working properly, but it just doesn't return anything at all.

Any advice as to how to go about this? I need to be able to grab the database results, and work with it in Silverlight. Currently, I can get the data in an object type not supported by Silverlight, but that sort of defeats the purpose.

+2  A: 

Using a DataTable is not recommanded with a Web Service as DataTable is not interoperable with other language that are not .NET compliant. See this Silverlight Forum Thread.

You should reconsider the return type of your web service.

See if a DataContract with WCF could solve your problem.

Pierre-Alain Vigeant
A: 

Silverlight like entities. Figure out the entity. Make another wcf service which calls the first one. Do your magic inside the 2nd wcf service - convert the datatable into an entity. And then from your silverlight call the second wcf service...

deostroll
A: 

Can you postmore information on your WCF service?

Have you defined a data contract?

[DataContract]
public class Vendor
{
    [DataMember]
    public int VendorID;

    [DataMember]
    public string AccountNumber;

    [DataMember]
    public string Name;

    [DataMember]
    public int CreditRate;

    [DataMember]
    public int PreferredVendorStatus;

    [DataMember]
    public int ActiveFlag;

    [DataMember]
    public string PurchasingWebServiceUrl;

    [DataMember]
    public DateTime ModifiedDate;
}

A data contract is necessary for the service to serialize your objects and for the client to know how to reassemble the object

Raphael
A: 

You can also use the tools from http://www.silverlightds.com they wrap all of the work for you.

vince