forked from simplefx/Simple.OData
-
Notifications
You must be signed in to change notification settings - Fork 192
Deleting entries
Jason Finch edited this page Aug 23, 2018
·
12 revisions
OData supports deletions only by resource key, so in case the entry is identified by non-key properties or multiple entries should be deleted, corresponding entry keys should first be retrieved on a client side and only then Delete request can be invoked for each key value. Simple.OData.Client simplifies non-key and multiple entry deletion by supporting passing an OData filter expression to a delete operation. Bear in mind however that filter-based deletions will typically result in execution of multiple OData requests.
await client
.For("Products")
.Key(1)
.DeleteEntryAsync();
await client
.For<Products>()
.Key(1)
.DeleteEntryAsync();
var x = ODataFilter.Expression;
await client
.For(x.Products)
.Key(1)
.DeleteEntryAsync();
Request URI: DELETE Products(1)
await client
.For("Products")
.Filter("length(ProductName)+eq+4")
.DeleteEntriesAsync();
await client
.For<Products>()
.Filter(x => x.ProductName.Length() == 4)
.DeleteEntriesAsync();
var x = ODataFilter.Expression;
await client
.For(x.Product)
.Filter(x.ProductName.Length() == 4)
.DeleteEntriesAsync();
Request URI: N/A (separate DELETE request for each entry matching search criteria)
See also:
Modifying data