disconnected context update
-
martes, 11 de septiembre de 2012 10:58
Hi
I am using V 5.1(rc)
I am building an application where I read records and then use another conext to update ( disconnected context ) I get error below.
var context = new context (); // just to show creation of a new context
var test = (from t in context.Tests select t).firstorDefault();
test.name = "changed";
Later in the application
var context1 = new context (); // just to show creation of a new context
context.saveChanges(Batch);
"<?xml version=\"1.0\" encoding=\"utf-8\"?><m:error xmlns:m=\"<m:code">http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\"><m:code /><m:message xml:lang=\"en-GB\">Since entity type 'MyModel.Test' has one or more etag properties, If-Match HTTP header must be specified for DELETE/PUT operations on this type.</m:message></m:error>"
- Editado Watty45 martes, 11 de septiembre de 2012 13:46
Todas las respuestas
-
martes, 11 de septiembre de 2012 16:09Moderador
As the error says, if the entity has an ETag, the client must use it when sending the update. If the entity on the client was retrieved through a request, the context tracks the ETag alongside the entity for you. If you attach the entity by hand, you must specify the ETag manually.
So you can use the AttachTo overload which takes additional parameter (the Tag): http://msdn.microsoft.com/en-us/library/cc646820(v=vs.103).aspx
To get the ETag, find the EntityDescriptor for the entity in question (this can be done by calling DataServiceContext.GetEntityDescriptor) on the first context and it has a property ETag.
Thanks,
Vitek Karas [MSFT]
-
viernes, 14 de septiembre de 2012 12:37
Hi Vitek
Thanks for the reply, to get the etag I was using
context.ReadingEntity += new EventHandler<ReadingWritingEntityEventArgs>(context_readingEntity); ( in this function I save the etag )
And I was calling the overload AttachTo to add the etag. Now tryng DS 5.1 and JSON light the ReadingEntity doesn't work and I was trying to find an alternative way to do this.
-
viernes, 14 de septiembre de 2012 15:39Moderador
ReadingEntity is not supported with JSON Light, mainly because that event exposes the XML representation of the entity, which doesn't exist with JSON Light. We're replacing this event with a different one which will be format agnostic...
The GetEntityDescriptor should work always though...
Thanks,
Vitek Karas [MSFT]
-
lunes, 17 de septiembre de 2012 7:57
Hi Vitek
Ok thats fab do you know if this will make it into 5.1 rc2 ?
Regards
-
lunes, 17 de septiembre de 2012 8:22Moderador
Hi,
I don't know myself... hopefully Ian will see this and respond (as he probably does know).
Thanks,
Vitek Karas [MSFT]
-
lunes, 17 de septiembre de 2012 17:16Moderador
The new event will not make it for 5.1 RTM. For now, GetEntityDescriptor should be best bet and it should be more faster that way. Let me know if you run into issues using GetEntityDescriptor.
We are definitely planning to add the new event asap after the 5.1 release.
Thanks
Pratik
This posting is provided "AS IS" with no warranties, and confers no rights.
- Marcado como respuesta Allen Li - AI3Microsoft Contingent Staff, Moderator lunes, 24 de septiembre de 2012 1:50
-
viernes, 25 de enero de 2013 10:33
Hi
We have now upgraded to 5.2 RTM, is there a new event to do the same as below ( also the WriteEntity ) for JSON ?
context.ReadingEntity += new EventHandler<ReadingWritingEntityEventArgs>(context_readingEntity);
Regards
Paul
-
viernes, 25 de enero de 2013 17:49Moderador
Regarding ReadingEntity w/ JSON, there isn't anything yet, unfortunately. Its a request we're hearing a LOT. We wanted to expose an equivalent format-independent event using ODataEntry, but we were not able to fit it in the 5.1 release or the subsequent releases for various reasons. The work is in progress now, but I cannot promise when it will be available.
Matt Meehan (WCF Data Services / OData)
-
lunes, 28 de enero de 2013 7:33
Hi Matt
Thanks for your reply, for our scheduling any clues for time scales is it weeks, months, years ?.
We wouldn't hold you to this.
Paul
-
lunes, 28 de enero de 2013 9:03
Hi Matt,
I'm trying to implement the same functionality and would also be interested in an potential timescale.
Ragrds
Ian
-
lunes, 28 de enero de 2013 17:59Moderador
Unfortunately this functionality just missed the cut off for the current release (version 5.3, coming out soon), but there's no reason it wouldn't make the next one. Our current cadence is about 6-8 weeks per release, which would put this some time in late March or early April. We hope to have a pre-release available sooner than that, especially given the recent surge in requests that we've seen for this feature. Things happen sometimes, so don't consider this a guarantee, but that's the team's plan as of right now.
Matt Meehan (WCF Data Services / OData)
-
jueves, 31 de enero de 2013 7:25
Hi Matt
Many thanks for your thoughts, we understand that scehdules change but it helps us that is one your radar and will be resolved . Is there a way to let me know when a version is arround so we can help any testing ?
Regards
Paul

