最佳实践:通用 asmx 数据加载 Web 方法或多 Web 方法

发布于 2024-10-29 22:25:32 字数 203 浏览 4 评论 0原文

我想知道从性能的角度来看哪种方法更好,是使用一种 Web 服务方法通过传递数据库表名称和键来加载数据更好,还是为每个数据库表使用单独的方法更好!知道我正在通过 ajax 请求使用 .net asmx。

很明显,从面向对象的角度来看,一种方法更好,因为它有一种函数类型“数据加载”,但性能如何? IIS 是否受此影响?制作多个 Web 服务“asmx 文件”还是只制作一个更好?

I'm wondering which is better approach from performance point of view, is it better to use one web-service method to load data by passing Database Table name and keys or is it better to use separate method for each database table! knowing that i'm using .net asmx through ajax requests.

it's obvious that one method is better from OO perspective since it have one function type 'data loading' but what about performance? does IIS affected by that or not? also is it better to make multi web-services 'asmx files' or just one!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

巡山小妖精 2024-11-05 22:25:32

我真的不认为创建单独的方法来处理不同表的数据获取是必要的。通过将额外的表名参数传递给 Web 服务调用,您可能会遇到的性能增益/损失太小,甚至无法考虑,除非您的表名确实很大,但我认为情况并非如此。

我什至会考虑做这样的事情的唯一原因是,如果我在性能改进方面没有其他事情可做,或者如果被迫这样做;-)。

如果您确实想优化请求大小,请尝试

  • 使用 JSON 序列化您的输入参数(如果您还没有这样做),
  • 请为您的网络服务使用无 cookie 域

希望这会有所帮助

I really dont think that creating separate methods for handling data fetch different tables is necessary. The performance gain\loss that u r likely to experience by passing an additional table name param to your webservice call would be too small to even consider unless your table names are really huge, which i dont think is the case.

The only reason i would even consider doing some thing like this is if i have nothing else to do in terms of performance improvement or if being forced to do it ;-).

If you really want to optimize your request size try

  • serializing your input params using JSON (if you are not doing it already)
  • use a cookieless domain for your webservice

hope this helps

漫漫岁月 2024-11-05 22:25:32

我认为服务级别不应该对数据库表有任何了解,就像理想情况下您不希望在控制器操作或 ASPX 后面的代码中看到数据访问代码一样。

就我个人而言,我更喜欢组织我的服务以匹配我的域模型。

例如,如果我有 CustomerOrderItem 类,我就会有相应的 Customer.asmxOrder.asmxItem.asmx 服务公开这些类中选定的方法。

I don't think the service level should have any knowledge of database tables, just like you ideally don't want to see data access code in a controller action or ASPX's code behind.

Personally, I prefer to organize my services to match my domain model.

If I have Customer, Order, and Item classes, for example, I would have corresponding Customer.asmx, Order.asmx, and Item.asmx services to expose selected methods within those classes.

淡淡離愁欲言轉身 2024-11-05 22:25:32

服务通常负责通过合同公开业务功能。我意识到 ASMX 服务确实没有最广泛意义上的“合同”概念,但是您将其视为服务支持的一组操作。您的目标是什么?您想将表格数据公开为服务吗?

Microsoft 堆栈上的服务技术自 ASMX 以来已经取得了长足的进步。也许是一个显而易见的问题,您看过 WCF 数据服务吗?

链接:

Services are typically responsible for exposing business functionality through a contract. I realize ASMX services really had not concept of "Contracts" in their broadest sense, however you think of it as a set of operations supported by the service. What is your goal here, do you want to expose tabular data as a service ?

Service technology on the Microsoft stack has come a long way from ASMX. Perhaps an obvious question, have you looked at WCF Data Services?

Links:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文