0

I'm using the AWS SDK for .NET, and I'm trying to perform a "scan" operation using the "in" operator.

The ScanCondition takes in three arguments, but I'm not sure what the last argument [the values] should be.

  • Is it an array of strings? (this returns empty, when it should return results)
  • Is it a comma-delimited list of strings? (this throws an error saying it could not convert a list of strings into a string)

I've tried a number of different things, and nothing has worked.

public void GetUsers()
{
    AmazonDynamoDBClient client = new AmazonDynamoDBClient("key", "secret", Amazon.RegionEndpoint.GetBySystemName("systemEndpoint");
    DynamoDBContext context = new DynamoDBContext(client);

    var results = context.Scan<User>(new ScanCondition("ID", ScanOperator.In, list /* what goes here? */));
}

2 Answers 2

3

The values argument should be of type object[].

In your example, (assuming your list is of type int[] or List), it needs to be cast to type object[] first.

var objectValues = list.Select(x => (object)x).ToArray();
var results = context.Scan<User>(new ScanCondition("ID", ScanOperator.In, objectValues));

It's a known usability issue with the API. If your ID property were of type string, it would work as you'd expect.

Sign up to request clarification or add additional context in comments.

Comments

1

As the documentation states the object needed is AttributeValueList. So you will need to wrap your strings as AttributeValues before passing them to the Scan command

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.