Using a DataTable with Silverlight

I have an interesting problem: I can get results from my WCF service to my Silverlight code as a DataTable. The problem is that Silverlight does not support DataTable objects. I thought a lot about what I can do, and the best I can think of is to pass it as a List.

Great, right? Nope. Now I get the same problem as before; nothing returns. The code shows that it works correctly, but it just returns nothing.

Any tips on how to do this? I need to be able to capture database results and work with it in Silverlight. Currently, I can get the data as an object that is not supported by Silverlight, but this view defeats the target.

+4
source share
3 answers

Using a DataTable is not recommended using the Web service, because the DataTable is not compatible with another language that is not compatible with .NET.

You should review the return type of your web service.

See if a DataContract with WCF can solve your problem.

+3
source

Silverlight as objects. Find out the essence. Make another wcf service that calls the first. Do your magic in the second wcf service - convert data to an object. And then from your silver light call the second wcf service ...

0
source

Can you post more details about 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 collect the object

0
source

All Articles