简体   繁体   English

OData v4变更集行为

[英]OData v4 Changeset behaviour

I'm implementing an OData v4 Service with WebApi and I also implemented support for OData Changesets using the code from https://damienbod.wordpress.com/2014/08/14/web-api-odata-v4-batching-part-10/ 我正在使用WebApi实现OData v4服务,并且还使用https://damienbod.wordpress.com/2014/08/14/web-api-odata-v4-batching-part-中的代码实现了对OData变更集的支持10 /

Basically this is working, but now I'm wonder about the correct behaviour when modifying the same entity from multiple requests in one changeset. 基本上这是可行的,但是现在我想知道在一个变更集中从多个请求修改同一实体时的正确行为。 Consider this example: 考虑以下示例:

Content-ID: 1 - POST ~/Entity 内容ID:1-POST〜/ Entity
-> Create new Entity. ->创建新实体。

Content-ID: 2 - PUT ~/Entity($Entity-ContentID1)/Company/$ref?$id=URI 内容ID:2-PUT〜/ Entity($ Entity-ContentID1)/ Company / $ ref?$ id = URI
-> Create link from new Entity to existing Company using the ContentID. ->使用ContentID创建从新实体到现有公司的链接。

Content-ID: 3 - POST ~/Entity($Entity-ContentID1)/ChangeState 内容ID:3-POST〜/ Entity($ Entity-ContentID1)/ ChangeState
-> Execute action to change the state of the newly created Entity. ->执行操作以更改新创建的实体的状态。

The ChangetState can only be executed, if a Company is linked. 如果公司链接,则只能执行ChangetState。 If a client sends all requests in this order and if I execute the requests in order, everything is fine. 如果客户端按此顺序发送所有请求,并且如果我按顺序执行请求,则一切正常。
But according to the OData Spec , requests in a Changesets are unordered . 但是根据OData Spec ,变更集中的请求是无序的

What is the expected result if a client sends request 3 before request 2? 如果客户端在请求2之前发送请求3,预期的结果是什么? With my current implementation this changeset will fail, but is this really okay? 在我当前的实现中,此变更集将失败,但这真的可以吗? It's quite hard for me to understand the correct semantic of changesets... 对于我来说,很难理解变更集的正确语义。

Batch requests are submitted as a single HTTP POST request to the batch endpoint of a service, these requests in a Changeset should be sent to service and proceed in original order. 批处理请求作为单个HTTP POST请求提交到服务的批处理终结点,Changeset中的这些请求应发送给服务并按原始顺序进行。

I think, the spec mean: requests in Changeset will be processed un-order, in our lab, we process with origin order, but different service can use different order, what you concerned is not necessary, client should'n expect same result for a changeset like your scenario, otherwise they should put in different changeset, then the result should be same. 我认为,规范的意思是:Changeset中的请求将按无序方式处理,在我们的实验室中,我们将按原始顺序进行处理,但是不同的服务可以使用不同的顺序,您不必担心,客户不应期望得到相同的结果像您的方案这样的变更集,否则它们应该放入不同的变更集,那么结果应该是相同的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM