从datatset返回类型 [英] retrun type from datatset
问题描述
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.
推荐答案
参考 - 为什么从WCF服务返回数据集或数据表不是一个好习惯?有哪些替代方案? [ ^ ]。
Refer - Why returning dataset or data table from WCF service is not a good practice? What are the Alternatives?[^].
返回来自Web服务的数据集通常不被视为良好实践。这些问题已在以下链接中详细记录:
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
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
总之,返回 DataSet
对象的最大问题来自Web服务似乎涉及序列化性能,非.NET互操作性。此外, DataSet
的通用多态特性通常高于运行时的数据结构,因此,WSDL定义不提供方法签名的完整描述。然而,与任何设计决策一样,您需要权衡成本与收益,并根据您的具体目标和约束确定最佳匹配。
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.
就替代方案而言,可以考虑使用通用集合(例如 List< yourClassHere>
),或者甚至考虑一些架构修订以允许使用ODATA。
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.
以下链接为通过Web服务返回实体提供了一些很好的背景参考。
http://msdn.microsoft.com/en-us/library/orm-9780596520281-01-14.aspx
http://www.codeproject.com / Articles / 127395 /实施WCF-实体服务框架
http://msdn.microsoft.com/ en-us / data / hh237663.aspx
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
在WCF服务中返回数据集不是最佳做法。以下帮助你招募的链接。
如何从WCF服务返回数据集
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
使用下面的代码,这里可以使用数据表而不是数据集。
public DataSet GetData()
{
DataSet ds = new DataSet();
//添加您的逻辑
返回ds;
}
Use below code, here you can use datatable instead of dataset.
public DataSet GetData()
{
DataSet ds = new DataSet();
// Add your logic
return ds;
}
这篇关于从datatset返回类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!