private UpdateConnectionRequest CreateUpdateRequest(EntityChanges changes, int specificRevision, ApiOptions options)
        {
            var request = new UpdateConnectionRequest { Id = this.Id, Type = this.Type, Revision = specificRevision };
            ApiOptions.Apply(request, options);
            request.Revision = specificRevision;
            if (changes.PropertyUpdates != null && changes.PropertyUpdates.Count > 0)
                changes.PropertyUpdates.For(x => request.PropertyUpdates[x.Key] = x.Value);
            if (changes.AttributeUpdates != null && changes.AttributeUpdates.Count > 0)
                changes.AttributeUpdates.For(x => request.AttributeUpdates[x.Key] = x.Value);
            if (changes.AddedTags != null)
                request.AddedTags.AddRange(changes.AddedTags);
            if (changes.RemovedTags != null)
                request.RemovedTags.AddRange(changes.RemovedTags);

            return request;
        }
        protected override async Task<Entity> UpdateAsync(EntityChanges changes, int specificRevision, ApiOptions options, bool forceUpdate)
        {
            var request = CreateUpdateRequest(changes, specificRevision, options);

            // Check if an update is needed.
            if (request.PropertyUpdates.Count == 0 &&
                request.AttributeUpdates.Count == 0 &&
                request.AddedTags.Count == 0         &&
                request.RemovedTags.Count == 0  &&
                forceUpdate == false )
                return this;

            var response = await request.ExecuteAsync();
            if (response.Status.IsSuccessful == false)
                throw response.Status.ToFault();

            // 3. Update the last known state based on the differences
            Debug.Assert(response.Connection != null, "If status is successful, then updated connection should not be null.");
            return response.Connection;
        }
        private UpdateObjectRequest CreateUpdateRequest(EntityChanges changes, int specificRevision, ApiOptions options)
        {
            var request = new UpdateObjectRequest { Id = this.Id, Type = this.Type };
            ApiOptions.Apply(request, options);
            request.Revision = specificRevision;
            if (changes.PropertyUpdates != null && changes.PropertyUpdates.Count > 0)
                changes.PropertyUpdates.For(x => request.PropertyUpdates[x.Key] = x.Value);
            if (changes.AttributeUpdates != null && changes.AttributeUpdates.Count > 0)
                changes.AttributeUpdates.For(x => request.AttributeUpdates[x.Key] = x.Value);
            if (changes.AddedTags != null)
                request.AddedTags.AddRange(changes.AddedTags);
            if (changes.RemovedTags != null)
                request.RemovedTags.AddRange(changes.RemovedTags);

            // Check if acls are to be added
            request.AllowClaims.AddRange(this.Acl.Allowed);
            request.DenyClaims.AddRange(this.Acl.Denied);
            request.ResetClaims.AddRange(this.Acl.Reset);

            return request;
        }