Amazon.DynamoDBv2.AmazonDynamoDBClient.Query C# (CSharp) Метод

Query() публичный Метод

A Query operation uses the primary key of a table or a secondary index to directly access items from that table or index.

Use the KeyConditionExpression parameter to provide a specific value for the partition key. The Query operation will return all of the items from the table or index with that partition key value. You can optionally narrow the scope of the Query operation by specifying a sort key value and a comparison operator in KeyConditionExpression. You can use the ScanIndexForward parameter to get results in forward or reverse order, by sort key.

Queries that do not return results consume the minimum number of read capacity units for that type of read operation.

If the total number of items meeting the query criteria exceeds the result set size limit of 1 MB, the query stops and results are returned to the user with the LastEvaluatedKey element to continue the query in a subsequent operation. Unlike a Scan operation, a Query operation never returns both an empty result set and a LastEvaluatedKey value. LastEvaluatedKey is only provided if you have used the Limit parameter, or if the result set exceeds 1 MB (prior to applying a filter).

You can query a table, a local secondary index, or a global secondary index. For a query on a table or on a local secondary index, you can set the ConsistentRead parameter to true and obtain a strongly consistent result. Global secondary indexes support eventually consistent reads only, so do not specify ConsistentRead when querying a global secondary index.

/// An error occurred on the server side. /// /// Your request rate is too high. The AWS SDKs for DynamoDB automatically retry requests /// that receive this exception. Your request is eventually successful, unless your retry /// queue is too large to finish. Reduce the frequency of requests and use exponential /// backoff. For more information, go to Error /// Retries and Exponential Backoff in the Amazon DynamoDB Developer Guide. /// /// The operation tried to access a nonexistent table or index. The resource might not /// be specified correctly, or its status might not be ACTIVE. ///
public Query ( QueryRequest request ) : QueryResponse
request Amazon.DynamoDBv2.Model.QueryRequest Container for the necessary parameters to execute the Query service method.
Результат Amazon.DynamoDBv2.Model.QueryResponse
        public QueryResponse Query(QueryRequest request)
        {
            var marshaller = new QueryRequestMarshaller();
            var unmarshaller = QueryResponseUnmarshaller.Instance;

            return Invoke<QueryRequest,QueryResponse>(request, marshaller, unmarshaller);
        }

Usage Example

Пример #1
0
        private static void QueryByHashKey(string userId, AmazonDynamoDBClient client, DynamoDBContext context)
        {
            var selectQuery = string.Format("SELECT * FROM GameScores WHERE UserId = \"{0}\"", userId);

            Console.WriteLine("(AmazonDynamoDBClient) Running basic hash key query :\n\t\t{0}", selectQuery);
            var response = client.Query(selectQuery);
            Debug.Assert(response.Items.Count == 5);
            Debug.Assert(response.Items.TrueForAll(i => i["UserId"].S == userId));

            Console.WriteLine("(DynamoDBContext) Running basic hash key query :\n\t\t{0}", selectQuery);
            var gameScores = context.ExecQuery<GameScore>(selectQuery).ToArray();
            Debug.Assert(gameScores.Count() == 5);
            Debug.Assert(gameScores.All(gs => gs.UserId == userId));
        }
All Usage Examples Of Amazon.DynamoDBv2.AmazonDynamoDBClient::Query