This project is read-only.

Simple CRUD Sample

Kudos to Lohith for posting the first CRUD sample ever - thanks!

This sample builds on the Local Service Sample and adds a page that can be used to create, read, update and delete ideas from the idea service.

Some techniques demonstrated include:
  • How to craft requests that create, update and delete objects on ther service.
  • Using KnockoutJS to simplify data binding, and using its mapping extension to turn service-friendly objects into UI-friendly objects and vice-versa.
  • Adding a view model observable property, communicating, useful to avoid submitting multiple requests to the server at the same time.
  • Embedded metadata to support round-tripping Date values when using JSON formatting.

The sample file is ideas.htm, which can be added to the Local Service Sample to run.

Note: When deleting ideas that have dependent information, the server will send back an error. The local service is set to use verbose errors which can lead to disclosing security information. The better practice is to have the service recognize this case and return an error that the client can the process appropriately, but because this requires writing code on both client and server, this sample doesn't demonstrate this and instead shows the full serialized error on the UI.

Last edited Jun 18, 2011 at 2:09 AM by marcelolr, version 2


adefwebserver Apr 15, 2012 at 2:53 AM 
I posted a sample (based on ideas.htm) using LightSwitch at:

imageicon Dec 20, 2011 at 12:30 AM 
Nice sample, im testing out datajs and using this example code, it was quite easy to change to my own entities and read update, but my entities have foreign keys, and i simply cant figure out how to set thoose in the create events (have not testet updating them either), any guidance ?