Beispiel #1
0
        public async Task <T> PutItemAsync <T>(T value, bool returnOld = false, CancellationToken token = default)
        {
            var table   = DynamoMetadata.GetTable <T>();
            var request = new PutItemRequest
            {
                TableName    = table.Name,
                Item         = Converters.ToAttributeValues(this, value, table),
                ReturnValues = returnOld ? ReturnValue.ALL_OLD : ReturnValue.NONE,
            };

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

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

            return(Converters.FromAttributeValues <T>(table, response.Attributes));
        }