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
 Declaration Syntax| C# | 
public class QueryRequest : AmazonWebServiceRequest
 Members
 Members| All Members | Constructors | Methods | Properties | ||
| Icon | Member | Description | 
|---|---|---|
|  | QueryRequest()()()() | Initializes a new instance of the QueryRequest class | 
|  | AttributesToGet | 
            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.
             
             Constraints: | 
|  | ConsistentRead | 
            If set to true, then a consistent read is issued. Otherwise eventually-consistent is used.
             
             | 
|  | Count | 
            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.
             
             | 
|  | Equals(Object) | (Inherited from Object.) | 
|  | ExclusiveStartKey | 
            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.
             
             | 
|  | GetHashCode()()()() | Serves as a hash function for a particular type. (Inherited from Object.) | 
|  | GetType()()()() | Gets the type of the current instance.(Inherited from Object.) | 
|  | HashKeyValue | 
            Attribute value of the hash component of the composite primary key.
             
             | 
|  | Limit | 
            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.
             
             Constraints: | 
|  | RangeKeyCondition | 
            A container for the attribute values and comparison operators to use for the query.
             
             | 
|  | ScanIndexForward | 
            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).
             
             | 
|  | TableName | 
            The name of the table in which you want to query. Allowed characters are a-z, A-Z, 0-9, _ (underscore), -
            (hyphen) and . (period).
             
             Constraints: | 
|  | ToString()()()() | 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
             | 
 Examples
 Examples
          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
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.WithComparisonOperator("BEGINS_WITH"); condition.WithAttributeValueList(new AttributeValue { S = "The Adventures" }); // Define marker variable Key startKey = null; do { // 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) { Console.WriteLine("Item:"); foreach (var keyValuePair in item) { Console.WriteLine("{0} : S={1}, N={2}, SS=[{3}], NS=[{4}]", keyValuePair.Key, keyValuePair.Value.S, keyValuePair.Value.N, string.Join(", ", keyValuePair.Value.SS.ToArray()), string.Join(", ", keyValuePair.Value.SS.ToArray())); } } // Set marker variable startKey = result.LastEvaluatedKey; } while (startKey != null);
 Inheritance Hierarchy
 Inheritance Hierarchy| Object | ||
|  | AmazonWebServiceRequest | |
|  | QueryRequest | |
 See Also
 See Also