0

我是 WCF 的新手,正在尝试创建一个示例应用程序。我只是想知道调用 Service 方法来频繁获取数据是否是最佳实践。例如,在页面加载时,要使用数据库中的数据初始化下拉菜单、网格和文本框等控件,最好的方法是调用 WCF 服务或使用 ADO.net。

请解释。

谢谢你

4

2 回答 2

0

WCF and ADO.NET are complete different technologies. You will use them for different scenarios. WCF is used when creating scalable, distributed applications. ADO.NET is used as a database technology. They can be used together but they are certainly not interchangeable. 

If your Web Server which is running your ASP.NET code has direct access to the database server, you can use ADO.NET to query your database and initialize some values when loading the page. You don't WCF for this scenario.

WCF is a technology that is used for communication between servers. Normally, you would use WCF to setup a web service that can be called from other applications. The WCF service would then execute some code (for example, it could use ADO.NET to access a database that's accessible from the WCF Server) and then return the results to the client. Using WCF will have a performance penalty. You should only use it when you are creating a distributed application or if you want to divide your workload over multiple servers.

于 2012-07-16T11:52:30.023 回答
0

您考虑使用 WCF 服务检索这些值的原因是什么?

数据是来自外部方,还是您的数据库中有数据?如果您的数据库中有它,为什么要考虑进行 WCF 调用(额外的复杂性,性能损失)来检索这些数据?

于 2012-07-16T11:50:31.930 回答