Skip to main content
Home Forums Silverlight Programming WCF RIA Services .SubmitChanges() alternative?
4 replies. Latest Post by WilcoB on July 7, 2009.
(0)
vidalsasoon
Member
96 points
47 Posts
06-30-2009 1:27 PM |
Hello,
I want to submit changes to my domain source but for only *ONE* change at a time?
Maud
Contributor
3288 points
454 Posts
07-03-2009 5:16 AM |
As I understand, no other method to submit changes but SubmitChanges().
You coud use code to let DomainService submiting change after each modification
waldred
702 points
113 Posts
07-06-2009 9:22 PM |
I do want to ask, what do you mean by "one change"? Is this one property change on a single entity? Or one entity update that may include multiple property changes?
If the former option; generated client entities implement INotifyPropertyChanged so you could potentially listen to the PropertyChanged event and call SubmitChanges() as appropriate. (There are also some other codegen hook points that will be available in our next CTP.)
If the latter option; the application would need to understand what set of multiple property changes correspond to "one change" and you would need to track these change scopes and call SubmitChanges() yourself as appropriate.
Just be aware that either approach can result in a very chatty SL application.
07-07-2009 3:23 PM |
hi,
what I mean is: I have a collection of images (entities) that have been added to a parent entity.
The entitystate of each new image is flagged as "New" so they haven't been sent to the server yet.
Normally, I would just do submitchages() on my datacontext and the insert would happen in one shot and I would be happy. However, in this scenario, the images contain a lot of data and throw exceptions because I surpass the HTTP transfer limits for a response.
To overcome this limitation I was thinking of submitting one image at a time?
Anyway, I put that aspect of my app on ice until I see what's in the next CTP.
thx
WilcoB
720 points
137 Posts
07-07-2009 4:28 PM |
There won't be any changes in the next CTP that change this story. As such, I think these are some of the options you have:1. Whenever you add an entity with an image, submit it.2. When you want to submit all the images, create a new DomainContext per entity in your main DomainContext, and call SubmitChanges for each DomainContext. You will have to manually take care of any required synchronization with the main DomainContext (to propagate any updated values for your entities).3. Upload the images separately from your entities. E.g. you could have a service operation "string UploadPicture(byte[] image)", accepting an image and returning the path to or an id of the image. You could invoke that service operation for every image. You then let your entities just refer to the images (by id or path), and call SubmitChanges to persist the entities (which should now be a fairly cheap operation).4. Change the maximum request size in ASP.NET. (Not something I'd recommend.)