使用WCF将数据表更改保存到数据库吗? [英] Save datatable changes to database using wcf?

查看:71
本文介绍了使用WCF将数据表更改保存到数据库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.
我有一个wcf服务,可以从其Contract上获取DataTable

Hi.
I have a wcf service which I get a DataTable from on of it''s Contract

[OperationContract]
DataTable GetTable();



现在,我已经对该DataTable进行了更改,并且想要将更改保存回数据库.如何使用wcf服务做到这一点?



Now , I have made changes to that DataTable And I want to save changes back to Database . How can I do that with my wcf service?

Any help would be appreciated

推荐答案

首先,我建议不要将DataTables与WCF一起使用.原因是WCF应该全部与互操作性有关,这意味着任何客户端都可以使用WCF服务(Java,jQuery,.NET等).但是,当您使用Microsoft特定的格式(如DataTable)时,您将无法做到这一点.兼容性.相反,我建议发送回强类型模型,因为每个人都可以使用这些模型.

无论哪种方式,您都需要在WCF服务上创建新方法以公开更新点.例如,您可以创建一个称为UpdateTable的方法,该方法采用一个模型或一组模型.然后,您的WCF服务将使用该数据使用所提供的数据来更新数据库.
First, I would recommend against using DataTables with WCF. The reason is that WCF is supposed to be all about interoperability, meaning that any client can use the WCF service (Java, jQuery, .NET, etc.) However, when you use a Microsoft-specific format like DataTable, you are breaking that compability. Instead, I would recommend sending back strongly-typed models instead, since everyone can play with these.

Either way, you are going to need to create new methods on your WCF service to expose update points. For instance, you might create a method called UpdateTable that takes in a model or set of models. Your WCF service would then use the data to update your database with the provided data.


这篇关于使用WCF将数据表更改保存到数据库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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