locked
disconnected context update RRS feed

  • Question

  • 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.AttachTo(test);

    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>"


    • Edited by Watty45 Tuesday, September 11, 2012 1:46 PM
    Tuesday, September 11, 2012 10:58 AM

Answers

  • 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.

    Monday, September 17, 2012 5:16 PM
    Moderator

All replies

  • 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]

    Tuesday, September 11, 2012 4:09 PM
    Moderator
  • 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.

    Friday, September 14, 2012 12:37 PM
  • 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]

    Friday, September 14, 2012 3:39 PM
    Moderator
  • Hi Vitek

    Ok thats fab do you know if this will make it into 5.1 rc2 ?

    Regards

    Monday, September 17, 2012 7:57 AM
  • Hi,

    I don't know myself... hopefully Ian will see this and respond (as he probably does know).

    Thanks,


    Vitek Karas [MSFT]

    Monday, September 17, 2012 8:22 AM
    Moderator
  • 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.

    Monday, September 17, 2012 5:16 PM
    Moderator
  • 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

    Friday, January 25, 2013 10:33 AM
  • 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)

    Friday, January 25, 2013 5:49 PM
    Moderator
  • 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

    Monday, January 28, 2013 7:33 AM
  • Hi Matt,

    I'm trying to implement the same functionality and would also be interested in an potential timescale.

    Ragrds

    Ian 

    Monday, January 28, 2013 9:03 AM
  • 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)

    Monday, January 28, 2013 5:59 PM
    Moderator
  • 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

    Thursday, January 31, 2013 7:25 AM