为什么从WCF服务返回数据集或数据表不是一个好习惯?什么是替代品? [英] Why returning dataset or data table from WCF service is not a good practice? What are the Alternatives?

查看:162
本文介绍了为什么从WCF服务返回数据集或数据表不是一个好习惯?什么是替代品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用大学管理系统,我正在使用WCF服务,并且在使用DataTables和DataSet来获取数据库和数据库中的数据的服务是sql server。

I am working on University Management System on which I am using a WCF service and in the service I am using DataTables and DataSets for getting data from database and database is sql server.

我的问题是


  • 是否使用DataTables和DatasetsGood Practice或Bad Practice?

  • 如果不好,DataTable / DataSet的替代方法是什么?

  • 如果不好,主要原因是什么?

推荐答案

从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

总结,从Web服务返回 DataSet 对象的最大问题似乎涉及序列化性能,non.net互操作性。此外,$ code> 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/Implementing-a-WCF-Service-with-Entity-Framework
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服务返回数据集或数据表不是一个好习惯?什么是替代品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆