AWS SDK for .NET Documentation
QueryRequest Class
AmazonAmazon.DynamoDB.ModelQueryRequest Did this page help you?   Yes   No    Tell us about it...
Container for the parameters to the Query operation.

Gets the values of one or more items and its attributes by primary key (composite primary key, only).

Narrow the scope of the query using comparison operators on the RangeKeyValue of the composite key. Use the ScanIndexForward parameter to get results in forward or reverse order by range key.

Declaration Syntax
public class QueryRequest : AmazonWebServiceRequest
All MembersConstructorsMethodsProperties

Initializes a new instance of the QueryRequest class

List of Attribute names. If attribute names are not specified then all attributes will be returned. If some attributes are not found, they will not appear in the result.


1 -

If set to true, then a consistent read is issued. Otherwise eventually-consistent is used.

If set to true, Amazon DynamoDB returns a total number of items that match the query parameters, instead of a list of the matching items and their attributes. Do not set Count to true while providing a list of AttributesToGet, otherwise Amazon DynamoDB returns a validation error.

Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Primary key of the item from which to continue an earlier query. An earlier query might provide this value as the LastEvaluatedKey if that query operation was interrupted before completing the query; either because of the result set size or the Limit parameter. The LastEvaluatedKey can be passed back in a new query request to continue the operation from that point.

Serves as a hash function for a particular type.
(Inherited from Object.)
Gets the type of the current instance.
(Inherited from Object.)
Attribute value of the hash component of the composite primary key.

The maximum number of items to return. If Amazon DynamoDB hits this limit while querying the table, it stops the query and returns the matching values up to the limit, and a LastEvaluatedKey to apply in a subsequent operation to continue the query. Also, if the result set size exceeds 1MB before Amazon DynamoDB hits this limit, it stops the query and returns the matching values, and a LastEvaluatedKey to apply in a subsequent operation to continue the query.


1 -

A container for the attribute values and comparison operators to use for the query.

Specifies forward or backward traversal of the index. Amazon DynamoDB returns results reflecting the requested order, determined by the range key. The default value is true (forward).

The name of the table in which you want to query. Allowed characters are a-z, A-Z, 0-9, _ (underscore), - (hyphen) and . (period).


3 - 255

Returns a string that represents the current object.
(Inherited from Object.)
WithAttributesToGet(array<String>[]()[][]) Obsolete.
Adds elements to the AttributesToGet collection

WithAttributesToGet(IEnumerable<(Of <<'(String>)>>)) Obsolete.
Adds elements to the AttributesToGet collection

WithConsistentRead(Boolean) Obsolete.
Sets the ConsistentRead property

WithCount(Boolean) Obsolete.
Sets the Count property

WithExclusiveStartKey(Key) Obsolete.
Sets the ExclusiveStartKey property

WithHashKeyValue(AttributeValue) Obsolete.
Sets the HashKeyValue property

WithLimit(Int32) Obsolete.
Sets the Limit property

WithRangeKeyCondition(Condition) Obsolete.
Sets the RangeKeyCondition property

WithScanIndexForward(Boolean) Obsolete.
Sets the ScanIndexForward property

WithTableName(String) Obsolete.
Sets the TableName property


The following example shows how to query items in a table.
Note: the Query operation retrieves items that have the same hash-key. This means that the Query operation is only supported on tables with both a hash- and a range-key.
Note: the RangeKeyCondition for Query is limited to indexable comparisons. These are EQ, LE, LT, GE, GT, BETWEEN, and BEGINS_WITH.
We will now retrieve all items where the hash-key is "Mark Twain" and the range-key begins with the string "The Adventures".

CopyQuery sample
// Create a client
AmazonDynamoDBClient client = new AmazonDynamoDBClient();

// Define item hash-key to be string value "Mark Twain"
AttributeValue hashKey = new AttributeValue { S = "Mark Twain" };

// Define query condition to search for range-keys that begin with the string "The Adventures"
Condition condition = new Condition();
condition.WithAttributeValueList(new AttributeValue { S = "The Adventures" });

// Define marker variable
Key startKey = null;

    // Create Query request
    QueryRequest request = new QueryRequest
        TableName = "SampleTable",
        ExclusiveStartKey = startKey,
        HashKeyValue = hashKey,
        RangeKeyCondition = condition

    // Issue request
    QueryResult result = client.Query(request).QueryResult;

    // View all returned items
    List<Dictionary<string, AttributeValue>> items = result.Items;
    foreach (Dictionary<string, AttributeValue> item in items)
        foreach (var keyValuePair in item)
            Console.WriteLine("{0} : S={1}, N={2}, SS=[{3}], NS=[{4}]",
                string.Join(", ", keyValuePair.Value.SS.ToArray()),
                string.Join(", ", keyValuePair.Value.SS.ToArray()));

    // Set marker variable
    startKey = result.LastEvaluatedKey;
} while (startKey != null);
Inheritance Hierarchy
See Also

Assembly: AWSSDK (Module: AWSSDK) Version: (