Modifying entities offline is done by calling the
Normally there will be no combining or reordering of the queued requests. Multiple
updateEntity() invocation against the same entity will result in a series of OData requests.
The sample below demonstrates usage of
editLink in modifying entities.
/// Declare a new Track entity let track = ... /// Create a local Track entity try eventService.createEntity(track) /// Update property values track.name = "General" ... /// Update the entity try eventService.updateEntity(track)
Because a download may take place before any upload, an entity modified locally may receive an update from the OData service. When that happens, the offline store uses the latest state from the OData service and reapplies all the outstanding requests from the queue for that same entity.
By default empty
PATCH requests, that is, requests that do not change anything, are not sent. Usually such requests will be discarded.
Sometimes such requests are expected to remain and should be sent to the back end. For example, an empty
PATCH request may indicate that a parent entity needs to be updated when a child is added. Another example is that, a set of request need to be sent for a group of entities at the same time, although some of those entities haven't been changed.
To force an empty
PATCH request to be sent, provide a
RequestOptions instance with
sendEmptyUpdate property set to
true when performing the
/// Locate the entity to send an empty PATCH let track = ... /// Do other jobs ... /// Set request options let options = RequestOptions() options.sendEmptyUpdate = true /// Since sending empty update is enabled, the call would send a PATCH request with empty request body try eventService.updateEntity(track, headers: HttpHeaders.empty, options: options)