Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi.
I have a wcf service which I get a DataTable from on of it's Contract

C#
[OperationContract]
DataTable GetTable();


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
Posted
Comments
[no name] 30-Jul-12 9:50am    
" want to save changes "... so go ahead and do it. Telling someone what you want does not make it a question.
Sandeep Mewara 30-Jul-12 13:21pm    
Tried anything so far?
mojtaba pirveisi 31-Jul-12 1:45am    
No , because I have no idea how to do that . If I have SqlDataAdapter Object , I could do that with SqlDataAdapter.Update() method , But I only have DataTable Object !

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900