AWS SDK Version 4 for .NET
API Reference

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.

Inheritance Hierarchy

System.Object
  Amazon.DynamoDBv2.DataModel.QueryConditional

Namespace: Amazon.DynamoDBv2.DataModel
Assembly: AWSSDK.DynamoDBv2.dll
Version: 3.x.y.z

Syntax

C#
public class QueryConditional

The QueryConditional type exposes the following members

Methods

Note:

Asynchronous operations (methods ending with Async) in the table below are for .NET 4.7.2 or higher.

NameDescription
Public Method AndHashKeyEqualTo(string, object)

Adds a condition to the query that specifies the hash key must equal the given value.

Public Method AndRangeKeyBeginsWith(string, object)

Adds a range key begins-with condition to the query.

Public Method AndRangeKeyBetween(string, object, object)

Adds a range key between condition to the query.

Public Method AndRangeKeyEqualTo(string, object)

Adds a range key equality condition to the query.

Public Method AndRangeKeyGreaterThan(string, object)

Adds a range key greater-than condition to the query.

Public Method AndRangeKeyGreaterThanOrEqual(string, object)

Adds a range key greater-than-or-equal condition to the query.

Public Method AndRangeKeyLessThan(string, object)

Adds a range key less-than condition to the query.

Public Method AndRangeKeyLessThanOrEqual(string, object)

Adds a range key less-than-or-equal condition to the query.

Public Method Static Method HashKeyEqualTo(string, object)

Creates a query conditional for a hash key equality condition.

Public Method Static Method HashKeysEqual(Dictionary<String, Object>)

Creates a Amazon.DynamoDBv2.DataModel.QueryConditional object with the specified hash keys.

Examples

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);
            

Remarks

This class supports querying DynamoDB tables and Global Secondary Indexes (GSIs) with various key configurations:

Single hash key queriesComposite hash key queries (multiple hash keys)Single rage key queries with various operatorsComposite range key conditions queries (multiple range keys)

Version Information

.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