Web 服务/wcf 服务,返回数据集是否更好? [英] web service / wcf service, is it ever better to return a dataset?

查看:46
本文介绍了Web 服务/wcf 服务,返回数据集是否更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,从我所看到的关于服务的情况来看,自定义对象似乎是编写服务以返回数据时要走的路.如果我正在编写将用于 1) 填充数据库或 2) 为网站提供信息的服务,是否有返回数据集/数据表而不是具有所有这些的自定义对象列表的用途信息?

So from what I've seen about services, custom objects seem to be the way to go when the service is written to return data. If I am writing a service that will be used to 1) populate a database, or 2) provide information for a web site, is there ever a use for returning a dataset/datatable as opposed to a list of custom objects with all of that information?

谢谢

推荐答案

我认为通过线路发送 DataSet 的最大问题,假设您拥有"两端,是 DataSet 承载的绝对重量" - 与它的关系能力等,它的作用远不止传输数据.一个简单的对象集合应该更加轻量级.

I think the biggest problem with sending DataSets over the wire, assuming you "own" both ends, is the sheer "weight" a DataSet carries - with it's relationship capabilities etc. it does far more than transport data. A simple collection of objects should be substantially more lightweight.

如果您不拥有"两端,或者可能有其他客户端使用您的服务,那么 DataSet 就是一个互操作性噩梦.

If you don't "own" both ends, or may have other clients using your service, then the DataSet is an interopability nightmare.

如果您不关心这些问题中的任何一个,并且您觉得对象集合太工作"(例如,如果您只是要将其转换回另一端的 DataSet),那么那是你的电话.

If you don't care about either of these issues, and you feel that a collection of objects is too much "work" (e.g. if you're just going to translate it back to a DataSet on the other end) then that's your call.

有一篇关于它的好文章 这里.

There's a good article on it over here.

这篇关于Web 服务/wcf 服务,返回数据集是否更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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