silverlight-3.0wcf-ria-services

Ria Services - SubmitChanges() problem. Possible to limit to one change at a time?


I would like to submit a collection of entities one at a time.

There are 2 reasons for this: - I'm uploading a lot of data and submitting more than one change exceeds the http limit for these transfers. (i don't want to change this limit) - I want to see the progress of each item getting submitted.

Example: Suppose I have an album and each album has a collection of photos (entities). If the user adds some photos, I want to upload one photo at a time and not the whole chunk at once.


Solution

  • If you'd like to Submit one change at a time, simply call SubmitChanges upon committing an edit, or adding or deleting an entity...

    Typically in your UI if you have some sort of commit button, then tie that to do two things - both the local commit, and subsequent SubmitChanges.

    Note you can also override ValidateChangeSet on your DomainService to ensure there is only one operation in the ChangeSet. This ensures clients don't inadvertently try to commit more than one change at a time...