Reputation: 43
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.
Upvotes: 4
Views: 8883
Reputation: 23093
Using a DataTable is not recommended with a Web Service as DataTable is not interoperable with other language that are not .NET compliant.
You should reconsider the return type of your web service.
See if a DataContract with WCF could solve your problem.
Upvotes: 3
Reputation: 8192
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
Upvotes: 0
Reputation: 11985
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...
Upvotes: 0