1

I have the problem that our backend uses an OData-"like"-Processor which has some special functions. It is oriented at OData_2.0 So the question will be: What is the most OData like approach for this kind of the following requests

Our backend Data-Model has no single-attribute-keys. But it's recommended to be OData-Like if possible.

First: I need to delete several objects via one OData Request. My first idea is to use filters to define which objects should be deleted. But I', not sure if this is the right approach.

For Example: I want to delete all Items which have a price greater than 10.00

http://.../<oDataServiceX>/Item?$filter=ItemPrice gt 10.00

Second: When I want to delete an object which is not identifiable by one single key-attribute. How can I define that in the classical OData-Delete-Request-Syntax.

Is the following OData-like?

http://.../<oDataServiceX>/Item(1,54,2)  //3 Attributes which define the key for the Item

Or should I do a filter again? (If filter is a proper way of doing this).

http://.../<oDataServiceX>/Item?$filter=keyAttr1 eq 1 and keyAttr2 eq 54 and keyAttr 3 eq 2

2 Answers 2

0

You can't delete multiple entries in a single OData query, you need first to retrieve their keys and then send multiple delete requests. There are two ways to improve this process:

  1. Use OData batch to send all delete request in a single HTTP call.
  2. Use some of libraries that can simulate deletion using filter (internally they will issue multiple requests but for the application it will look like a single call). One of such libraries is Simple.OData.Client.

Hope this helps.

0

Odata v4 supports the format DELETE /entity(key1='', key2='') and so on.

However, for oData v2, one option could be to use the request body to pass some data over. DELETE /entity, with data in the body. The documentation states that the convention is to delete an entity by key. However, this was the approach followed when we had to delete by multiple keys for an odata v2 service. Also while implementing this using oData v2 libraries, we had to add a routing convention to support Delete without a key.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.