Returning a DataTable/DataSet in a service operation

A very frequently asked question in a WCF Data transfer service is how to return a DataTable/DataSet in a WCF service operation. The DataTable class is a member of the System.Data namespace within the .NET framework class library. You can create and use a DataTable independently or as a member of a DataSet, and DataTable objects can also be used in conjunction with other .NET framework objects.

There are various possible solutions for DataTable or DataSet transferring in a WCF service; we will go through the most common ones in this recipe.

Getting ready

In our sample service, we will demonstrate several means to return data from a DataTable to client consumers. The sample DataTable consists of ...

Get Microsoft Windows Communication Foundation 4.0 Cookbook for Developing SOA Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.