Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
Hi,

i want to return datatset,datatable and datareader from WCF.if i able to return it i some example code or web link how it was return form WCF.
Posted

Refer - Why returning dataset or data table from WCF service is not a good practice? What are the Alternatives?[^].
Quote:

Returning data sets from web services is not typically considered a “good practice”. The issues have been documented thoroughly in the following links:


http://msdn.microsoft.com/en-us/magazine/cc163751.aspx

http://www.4guysfromrolla.com/articles/051805-1.aspx

http://msdn.microsoft.com/en-us/magazine/cc188755.aspx


In summary, the biggest issues with returning DataSet objects from web services seem to involve serialization performance, non-.net interoperability. In addition, the generic, polymorphic nature of the DataSet generally high the data structure until runtime, as such, the WSDL definition does not provide a complete description of the method signature. As with any design decision, however, you need to weigh the costs vs the benefits and determine the best fit given your specific goals and constraints.


In terms of alternatives, you could consider using a generic collection (e.g. List<yourClassHere>) or maybe even consider some architecture revisions to permit the use of ODATA.


The following links provide some good background reference for returning entities via web services.
http://msdn.microsoft.com/en-us/library/orm-9780596520281-01-14.aspx
http://www.codeproject.com/Articles/127395/Implementing-a-WCF-Service-with-Entity-Framework
http://msdn.microsoft.com/en-us/data/hh237663.aspx

 
Share this answer
 
It's not best practice the return the dataset in the WCF service.Following link which helps your recruitment.

How to return dataset from a WCF service
 
Share this answer
 
v2
Use below code, here you can use datatable instead of dataset.

public DataSet GetData()
{
DataSet ds = new DataSet();

// Add your logic

return ds;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900