AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
Represents a conditional expression for DynamoDB queries, supporting both simple and composite key conditions. Provides a fluent API for building query conditions with hash keys and range keys.
Namespace: Amazon.DynamoDBv2.DataModel
Assembly: AWSSDK.DynamoDBv2.dll
Version: 3.x.y.z
public class QueryConditional
The QueryConditional type exposes the following members
| Name | Description | |
|---|---|---|
|
AndHashKeyEqualTo(string, object) |
Adds a condition to the query that specifies the hash key must equal the given value. |
|
AndRangeKeyBeginsWith(string, object) |
Adds a range key begins-with condition to the query. |
|
AndRangeKeyBetween(string, object, object) |
Adds a range key between condition to the query. |
|
AndRangeKeyEqualTo(string, object) |
Adds a range key equality condition to the query. |
|
AndRangeKeyGreaterThan(string, object) |
Adds a range key greater-than condition to the query. |
|
AndRangeKeyGreaterThanOrEqual(string, object) |
Adds a range key greater-than-or-equal condition to the query. |
|
AndRangeKeyLessThan(string, object) |
Adds a range key less-than condition to the query. |
|
AndRangeKeyLessThanOrEqual(string, object) |
Adds a range key less-than-or-equal condition to the query. |
|
HashKeyEqualTo(string, object) |
Creates a query conditional for a hash key equality condition. |
|
HashKeysEqual(Dictionary<String, Object>) |
Creates a Amazon.DynamoDBv2.DataModel.QueryConditional object with the specified hash keys. |
Simple hash key query:
var condition = QueryConditional.HashKeyEqualTo("UserId", "user123");
var results = context.Query<User>(condition);
Composite hash key query with range condition:
var condition = QueryConditional.HashKeyEqualTo("UserId", "user123")
.AndHashKeyEqualTo("OrderId", "order456")
.AndRangeKeyGreaterThan("Timestamp", 1000);
Multiple range key conditions:
var condition = QueryConditional.HashKeyEqualTo("Category", "electronics")
.AndRangeKeyEqualTo("Status", "active")
.AndRangeKeyBetween("Price", 100, 500);
This class supports querying DynamoDB tables and Global Secondary Indexes (GSIs) with various key configurations:
.NET:
Supported in: 8.0 and newer, Core 3.1
.NET Standard:
Supported in: 2.0
.NET Framework:
Supported in: 4.7.2 and newer