コード例 #1
0
        public virtual async Task <Response> UpsertAsync(IDictionary <string, object> entity, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(entity, nameof(entity));

            //TODO: Create Resource strings
            if (!entity.TryGetValue(TableConstants.PropertyNames.PartitionKey, out var partitionKey))
            {
                throw new ArgumentException("The entity must contain a PartitionKey value", nameof(entity));
            }

            if (!entity.TryGetValue(TableConstants.PropertyNames.RowKey, out var rowKey))
            {
                throw new ArgumentException("The entity must contain a RowKey value", nameof(entity));
            }

            return(await _tableOperations.UpdateEntityAsync(_table,
                                                            partitionKey as string,
                                                            rowKey as string,
                                                            tableEntityProperties : entity.ToOdataAnnotatedDictionary(),
                                                            queryOptions : new QueryOptions()
            {
                Format = _format
            },
                                                            cancellationToken : cancellationToken).ConfigureAwait(false));
        }