2

I realize this is answered in the documentation (basically, "use the dot syntax"), but I'm still missing something. I'm using the .NET SDK and need to be able to select just a few attributes from a scan, one of which is a boolean inside a Map attribute. Note that I'm not trying to filter the results. I want all of the items, but I only want some of the attributes returned to me.

var config = new ScanOperationConfig
{
    AttributesToGet = new List<string> { "foo.bar" },
    Select = SelectValues.SpecificAttributes
};
var search = Table.Scan(config);
var documents = await search.GetRemainingAsync();

This code gets me the items I expect, but it's missing the "foo.bar" attribute. I know I can select the entire foo object, but I'm trying to minimize the amount of data handed back. I don't want the other attributes inside the foo object.

The relevant attribute of the item has the following JSON format:

{
    "foo": {
        "bar": true
    }
}

I checked spelling, case sensitivity, etc. to no avail. Any idea what's wrong?

1 Answer 1

2

Instead of using Table.Scan, use the AmazonDynamoDBClient and you get more options.

The Client's ScanAsync method takes a ScanRequest which has a ProjectionExpression string. This is not present on the ScanOperationConfig class and that was the source of confusion.

Use the ProjectionExpression like so:

var scanRequest = new ScanRequest(Table.TableName)
{
    ProjectionExpression = "foo.bar"
};

According to the documentation on ProjectionExpression:

ProjectionExpression replaces the legacy AttributesToGet parameter.

I didn't realize AttributesToGet was legacy until finally looking at the client for a totally unrelated problem and happened to find my answer to this problem.

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

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.