locked
Binding and Architecture Design Question RRS feed

  • Question

  • Hi,

    Easy points here for someone!

    I am a bit confused about how you can use Silverlight and WCF to update a database. I know how to write a WCF Service to read the database and put that data into Silverlight controls, but now I need to do it the other way round.

    For example, let's say that I have a textbox that allows the user to input their name. I understand how to create a class and bind that using two-way binding to the textbox so that whatever they enter is persisted in the class...and when they click 'submit' I could call a WCF service to read the data from the class and store in the db. Is that the way to do it?

    For example, I was wondering if it's possible to have the textbox bound directly to a table in the database via a WCF service? I imagine not.

    Thanks,

    Richard

    Monday, October 20, 2008 11:28 AM

Answers

  • Your approach sounds fine to me: use 2 way binding and update your database via the WCF service. 

    Monday, October 20, 2008 11:38 AM
  • To store data in a database you have to go through a web service operation that writes in the database. So yes, you can databind an object with the textbox, or query directly the textbox.Text and invoke the service with the control's value.

    You should be able to use SQL Server's native xml web services to store data directly into the DB without doing any server side coding. Maybe this is closer to what you are looking for.

    And, no, I don't know anyway to bind a control to a table in SL.

    Monday, October 20, 2008 1:43 PM
  • You can also use ADO.NET Data Services for simple CRUD operations.  You do have to worry about concurrency when you have services exposed and multiple users changing information.

    Monday, October 20, 2008 1:51 PM

All replies

  • Your approach sounds fine to me: use 2 way binding and update your database via the WCF service. 

    Monday, October 20, 2008 11:38 AM
  • To store data in a database you have to go through a web service operation that writes in the database. So yes, you can databind an object with the textbox, or query directly the textbox.Text and invoke the service with the control's value.

    You should be able to use SQL Server's native xml web services to store data directly into the DB without doing any server side coding. Maybe this is closer to what you are looking for.

    And, no, I don't know anyway to bind a control to a table in SL.

    Monday, October 20, 2008 1:43 PM
  • You can also use ADO.NET Data Services for simple CRUD operations.  You do have to worry about concurrency when you have services exposed and multiple users changing information.

    Monday, October 20, 2008 1:51 PM
  • Thanks for the replies and confirming that my idea is correct. 

    You should be able to use SQL Server's native xml web services to store data directly into the DB without doing any server side coding. Maybe this is closer to what you are looking for.

    Thanks for the link, but I don't want to build a new app. that uses a deprecated technology - XML WS will be removed in a future version of SQL 2008. So I'll stick to WCF services, thanks for the suggestion though.

    You can also use ADO.NET Data Services for simple CRUD operations.  You do have to worry about concurrency when you have services exposed and multiple users changing information.

     

    ADO.Net DS is one option I am considering, but whichever I use concurrent updates are something I have to be concerned about, which is why I plan to let stored procedures do the actual updates with transactions and have the services retry updates on locked resources and keep the front-end informed in such cases.

    Tuesday, October 21, 2008 8:41 AM