I have been tasked with implementing a WCF service in VB.NET. This WCF service will be consumed by our own .NET Windows Forms application and provide data from a SQL Server database. The data will be displayed in a third party grid (Infragistics).
Originally I was going to use ADO.NET and return a datatable or dataset from SQL within the WCF service but I have read too many articles encouraging me to stay away from returning datatables over the internet. I am not worried about the interoperability but I am worried about the size/speed of the process. This had lead me to start using linq to sql to return entities which I can pass over the internet (.dbml)
The problem:
A lot of our data comes from stored procedures, these stored procedures return result sets that are a mix-match of existing tables and therefore does not match any return type. I have imported a stored procedure that returns (Auto-generated Type) however when I try and return this type over the WCF service I get this error in the tracelog:
Type
System.Data.Linq.SqlClient.SqlProvider+SingleResult’1[benchmark_prd_colour_findResult]
cannot be serialized. Consider marking it with the
DataContractAttribute attribute, and marking all of its members you
want serialized with the DataMemberAttribute attribute. If the type
is a collection, consider marking it with the
CollectionDataContractAttribute. See the Microsoft .NET Framework
documentation for other supported types.
Please let me know what I need to be doing to be able to return the results of a stored procedure when the results don’t match any particular existing table
Translate it to VB! (Sorry, didnt see the tag… Assumed C#)
Build your own object – and mark this up like this:
Then populate this when getting the result of your stored proc
Then if you pass the MyObject instance in your WCF call it should work.