I have successfully implented the optimistic concurrency sample from the JayData site http://jaydata.org/blog/optimistic-concurrency-support-in-jaydata-1.2 with a WCF DataService in the back, just like in the sample.
Now, someone in charge decided that we need to change the OData backend in our project to Web Api.
But I can't get the sample to work with Web Api.
My first try: just switch out the backend, all the Javascript is the same. This results in the token being undefined.
When creating the Entity description with the Jaydata SvcUtil, it will look like this:
'token': {
type: 'Edm.Binary'
},
The token will then show up as [UInt8Array], but when executing the saveItems() command, both items will be saved, as it won't send the token in the If-Match header. As soon as I add concurrencyMode: $data.ConcurrencyMode.Fixed to the entity description, the token will be undefined again.
Is there something I would have to implement on the server side for my OData controllers to make this work? Or do I have to add something else to my Entities, maybe for Web Api, it is not sufficient to have the token as byte[] with the [Timestamp] attribute?
Disclaimer: I work for the JayData project
I am afraid optimistic concurrency is only supported in the Batch payload format. As of writing the use of the Batch payload format for WebAPI OData is still not working both in Olingo and in JayData 1.3.x and 1.4.x- however we are planning to have this support being available in March - but only for OData v4.
While the WebAPI OData is superb, make sure you review your requirements and double check regarding their availability in WebAPI OData - as we run into some difficulties when migrated large projects...