コード例 #1
0
        public async Task UpdateItemAsync <T>(DynamoUpdateItem update, CancellationToken token = default)
        {
            var request = ToUpdateItemRequest <T>(update);

            await ExecAsync(async() =>
                            await DynamoDb.UpdateItemAsync(request, token).ConfigAwait()).ConfigAwait();
        }
コード例 #2
0
        public async Task <bool> UpdateItemAsync <T>(UpdateExpression <T> update, CancellationToken token = default)
        {
            try
            {
                await ExecAsync(async() =>
                                await DynamoDb.UpdateItemAsync(update, token).ConfigAwait()).ConfigAwait();

                return(true);
            }
            catch (ConditionalCheckFailedException)
            {
                return(false);
            }
        }
コード例 #3
0
        public async Task <T> UpdateItemNonDefaultsAsync <T>(T value, bool returnOld = false, CancellationToken token = default)
        {
            var table   = DynamoMetadata.GetTable <T>();
            var request = new UpdateItemRequest
            {
                TableName        = table.Name,
                Key              = Converters.ToAttributeKey(this, table, value),
                AttributeUpdates = Converters.ToNonDefaultAttributeValueUpdates(this, value, table),
                ReturnValues     = returnOld ? ReturnValue.ALL_OLD : ReturnValue.NONE,
            };

            var response = await ExecAsync(async() =>
                                           await DynamoDb.UpdateItemAsync(request, token).ConfigAwait()).ConfigAwait();

            if (response.Attributes.IsEmpty())
            {
                return(default);