Represents a condition to be compared with an attribute value. This condition can be used with DeleteItem, PutItem or UpdateItem operations; if the comparison evaluates to true, the operation succeeds; if not, the operation fails. You can use ExpectedAttributeValue in one of two different ways:
  • Use AttributeValueList to specify one or more values to compare against an attribute. Use ComparisonOperator to specify how you want to perform the comparison. If the comparison evaluates to true, then the conditional operation succeeds.

  • Use Value to specify a value that DynamoDB will compare against an attribute. If the values match, then ExpectedAttributeValue evaluates to true and the conditional operation succeeds. Optionally, you can also set Exists to false, indicating that you do not expect to find the attribute value in the table. In this case, the conditional operation succeeds only if the comparison evaluates to false.

Value and Exists are incompatible with AttributeValueList and ComparisonOperator. Note that if you use both sets of parameters at once, DynamoDB will return a ValidationException exception.

コード例 #1
0
ファイル: ExpectedState.cs プロジェクト: rossmas/aws-sdk-net
        /// <summary>
        /// Converts this ExpectedValue instance to Amazon.DynamoDBv2.Model.ExpectedAttributeValue
        /// </summary>
        /// <returns>Amazon.DynamoDBv2.Model.ExpectedAttributeValue</returns>
        public ExpectedAttributeValue ToExpectedAttributeValue()
        {
            var eav = new ExpectedAttributeValue();

            if (this.Exists)
            {
                eav.ComparisonOperator = EnumMapper.Convert(this.Comparison);
                foreach (var val in this.Values)
                    eav.AttributeValueList.Add(val.ConvertToAttributeValue());
            }
            else
                eav.Exists = this.Exists;

            return eav;
        }
コード例 #2
0
ファイル: DynamoDBEntry.cs プロジェクト: rossmas/aws-sdk-net
        internal ExpectedAttributeValue ConvertToExpectedAttributeValue()
        {
            AttributeValue attributeValue = ConvertToAttributeValue();

            ExpectedAttributeValue expectedAttribute = new ExpectedAttributeValue();
            if (attributeValue == null)
            {
                expectedAttribute.Exists = false;
            }
            else
            {
                expectedAttribute.Exists = true;
                expectedAttribute.Value = attributeValue;
            }

            return expectedAttribute;
        }
コード例 #3
0
        /// <summary>
        /// Converts this ExpectedValue instance to Amazon.DynamoDBv2.Model.ExpectedAttributeValue
        /// </summary>
        /// <param name="conversion">Conversion to use for converting .NET values to DynamoDB values.</param>
        /// <returns>Amazon.DynamoDBv2.Model.ExpectedAttributeValue</returns>
        public ExpectedAttributeValue ToExpectedAttributeValue(DynamoDBEntryConversion conversion)
        {
            var eav = new ExpectedAttributeValue();

            if (this.Exists)
            {
                eav.ComparisonOperator = EnumMapper.Convert(this.Comparison);
                foreach (var val in this.Values)
                    eav.AttributeValueList.Add(val.ConvertToAttributeValue(new DynamoDBEntry.AttributeConversionConfig(conversion)));
            }
            else
                eav.Exists = this.Exists;

            return eav;
        }