private async Task <IActionResult> Update( EdmEntityObject edmEntityObject, bool isFullReplaceUpdate, CancellationToken cancellationToken) { EnsureInitialized(); CheckModelState(); var path = GetPath(); var entitySet = path.NavigationSource as IEdmEntitySet; if (entitySet == null) { throw new NotImplementedException(Resources.UpdateOnlySupportedOnEntitySet); } var propertiesInEtag = GetOriginalValues(entitySet); if (propertiesInEtag == null) { throw new StatusCodeException((HttpStatusCode)428, Resources.PreconditionRequired); } // In case of type inheritance, the actual type will be different from entity type // This is only needed for put case, and does not need for patch case // For put request, it will create a new, blank instance of the entity. // copy over the key values and set any updated values from the client on the new instance. // Then apply all the properties of the new instance to the instance to be updated. // This will set any unspecified properties to their default value. var expectedEntityType = path.EdmType; var actualEntityType = path.EdmType as IEdmStructuredType; if (edmEntityObject.ActualEdmType != null) { expectedEntityType = edmEntityObject.ExpectedEdmType; actualEntityType = edmEntityObject.ActualEdmType; } var model = api.GetModel(); var updateItem = new DataModificationItem( entitySet.Name, expectedEntityType.GetClrType(model), actualEntityType.GetClrType(model), RestierEntitySetOperation.Update, RestierQueryBuilder.GetPathKeyValues(path), propertiesInEtag, edmEntityObject.CreatePropertyDictionary(actualEntityType, api, false)) { IsFullReplaceUpdateRequest = isFullReplaceUpdate, }; var changeSetProperty = HttpContext.GetChangeSet(); if (changeSetProperty == null) { var changeSet = new ChangeSet(); changeSet.Entries.Add(updateItem); // RWM: Seems like we should be using the result here. For something else. var result = await api.SubmitAsync(changeSet, cancellationToken).ConfigureAwait(false); } else { changeSetProperty.ChangeSet.Entries.Add(updateItem); await changeSetProperty.OnChangeSetCompleted().ConfigureAwait(false); } return(CreateUpdatedODataResult(updateItem.Resource)); }