diff --git a/sdk/src/Services/DynamoDBv2/Custom/DataModel/ContextInternal.cs b/sdk/src/Services/DynamoDBv2/Custom/DataModel/ContextInternal.cs
index d83c9e707fe9..416027f6c29e 100644
--- a/sdk/src/Services/DynamoDBv2/Custom/DataModel/ContextInternal.cs
+++ b/sdk/src/Services/DynamoDBv2/Custom/DataModel/ContextInternal.cs
@@ -331,7 +331,9 @@ private static bool ShouldSave(DynamoDBEntry entry, bool ignoreNullValues)
throw new InvalidOperationException("Unrecognized DynamoDBEntry object");
}
- // Deserializing DynamoDB document into an object
+ ///
+ /// Deserializes a DynamoDB document to an object
+ ///
private T DocumentToObject(ItemStorage storage, DynamoDBFlatConfig flatConfig)
{
Type type = typeof(T);
@@ -392,7 +394,9 @@ private void PopulateInstance(ItemStorage storage, object instance, DynamoDBFlat
}
}
- // Serializing an object into a DynamoDB document
+ ///
+ /// Serializes an object into a DynamoDB document
+ ///
private ItemStorage ObjectToItemStorage(T toStore, bool keysOnly, DynamoDBFlatConfig flatConfig)
{
if (toStore == null) return null;
@@ -762,8 +766,10 @@ private static bool IsSupportedDictionaryType(Type type, out Type keyType, out T
return true;
}
- // Deserializes a given Document to instance of targetType
- // Use only for property conversions, not for full item conversion
+ ///
+ /// Deserializes a given Document to instance of targetType
+ /// Use only for property conversions, not for full item conversion
+ ///
private object DeserializeFromDocument(Document document, Type targetType, DynamoDBFlatConfig flatConfig)
{
ItemStorageConfig storageConfig = StorageConfigCache.GetConfig(targetType, flatConfig, conversionOnly: true);
@@ -772,8 +778,11 @@ private object DeserializeFromDocument(Document document, Type targetType, Dynam
object value = DocumentToObject(targetType, storage, flatConfig);
return value;
}
- // Serializes a given value to Document
- // Use only for property conversions, not for full item conversion
+
+ ///
+ /// Serializes a given value to Document
+ /// Use only for property conversions, not for full item conversion
+ ///
private Document SerializeToDocument(object value, Type type, DynamoDBFlatConfig flatConfig)
{
ItemStorageConfig config = StorageConfigCache.GetConfig(type, flatConfig, conversionOnly: true);
@@ -782,7 +791,9 @@ private Document SerializeToDocument(object value, Type type, DynamoDBFlatConfig
return doc;
}
- // Get/Set object properties
+ ///
+ /// Get/Set object properties
+ ///
private static bool TrySetValue(object instance, MemberInfo member, object value)
{
FieldInfo fieldInfo = member as FieldInfo;
@@ -825,7 +836,9 @@ private static bool TryGetValue(object instance, MemberInfo member, out object v
}
}
- // Query/Scan building
+ ///
+ /// Query/Scan building
+ ///
private ScanFilter ComposeScanFilter(IEnumerable conditions, ItemStorageConfig storageConfig, DynamoDBFlatConfig flatConfig)
{
ScanFilter filter = new ScanFilter();
diff --git a/sdk/src/Services/DynamoDBv2/Custom/DataModel/QueryConfig.cs b/sdk/src/Services/DynamoDBv2/Custom/DataModel/QueryConfig.cs
new file mode 100644
index 000000000000..25fe58ce454f
--- /dev/null
+++ b/sdk/src/Services/DynamoDBv2/Custom/DataModel/QueryConfig.cs
@@ -0,0 +1,104 @@
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+using Amazon.DynamoDBv2.DocumentModel;
+using System;
+using System.Collections.Generic;
+
+namespace Amazon.DynamoDBv2.DataModel
+{
+ ///
+ /// Input for the Query operation in the object-persistence programming model
+ ///
+#if NET8_0_OR_GREATER
+ // The DataModel namespace doesn't support trimming yet, so annotate public classes/methods as incompatible
+ [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode(Custom.Internal.InternalConstants.RequiresUnreferencedCodeMessage)]
+#endif
+ public class QueryConfig : BaseOperationConfig
+ {
+ ///
+ /// Indicates whether a query should traverse the index backwards in descending order by range key value.
+ /// If the property is false (or not set), traversal shall be in ascending order.
+ ///
+ public bool? BackwardQuery { get; set; }
+
+ ///
+ /// Indicates the name of the index to query against.
+ /// This value is optional if the index name can be inferred from the call.
+ ///
+ public string IndexName { get; set; }
+
+ ///
+ /// The logical operator to apply to the filter conditions.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// If all of the conditions evaluate to true, then the entire filter evaluates to true.
+ ///
+ ///
+ ///
+ /// If at least one of the conditions evaluate to true, then the entire filter evaluates to true.
+ ///
+ ///
+ /// The default value is .
+ ///
+ public ConditionalOperatorValues ConditionalOperator { get; set; }
+
+ ///
+ /// Query filter for the Query operation. Evaluates the query results and returns only
+ /// the matching values. If you specify more than one condition, then by default all of the
+ /// conditions must evaluate to true. To match only some conditions, set to .
+ ///
+ ///
+ /// Note: Conditions must be against non-key properties.
+ ///
+ public List QueryFilter { get; set; }
+
+ ///
+ /// Property that directs to use consistent reads.
+ /// If property is not set, behavior defaults to non-consistent reads.
+ ///
+ ///
+ /// Refer to the
+ /// Read Consistency topic in the DynamoDB Developer Guide for more information.
+ ///
+ public bool? ConsistentRead { get; set; }
+
+ ///
+ /// If true, all properties are retrieved in UTC timezone while reading data from DynamoDB. Else, the local timezone is used.
+ ///
+ ///
+ /// This setting is only applicable to the high-level library. Service calls made via
+ /// will always return attributes in UTC.
+ ///
+ public bool? RetrieveDateTimeInUtc { get; set; }
+
+ ///
+ internal override DynamoDBOperationConfig ToDynamoDBOperationConfig()
+ {
+ var config = base.ToDynamoDBOperationConfig();
+ config.BackwardQuery = BackwardQuery;
+ config.IndexName = IndexName;
+ config.ConditionalOperator = ConditionalOperator;
+ config.QueryFilter = QueryFilter;
+ config.ConsistentRead = ConsistentRead;
+ config.RetrieveDateTimeInUtc = RetrieveDateTimeInUtc;
+
+ return config;
+ }
+ }
+}
diff --git a/sdk/src/Services/DynamoDBv2/Custom/DataModel/ScanConfig.cs b/sdk/src/Services/DynamoDBv2/Custom/DataModel/ScanConfig.cs
new file mode 100644
index 000000000000..53e2929eab58
--- /dev/null
+++ b/sdk/src/Services/DynamoDBv2/Custom/DataModel/ScanConfig.cs
@@ -0,0 +1,97 @@
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+using Amazon.DynamoDBv2.DocumentModel;
+using System;
+using System.Collections.Generic;
+
+namespace Amazon.DynamoDBv2.DataModel
+{
+ ///
+ /// Input for the Scan operation in the object-persistence programming model
+ ///
+#if NET8_0_OR_GREATER
+ // The DataModel namespace doesn't support trimming yet, so annotate public classes/methods as incompatible
+ [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode(Custom.Internal.InternalConstants.RequiresUnreferencedCodeMessage)]
+#endif
+ public class ScanConfig : BaseOperationConfig
+ {
+ ///
+ /// Indicates the name of the index to scan against.
+ /// This value is optional if the index name can be inferred from the call.
+ ///
+ public string IndexName { get; set; }
+
+ ///
+ /// The logical operator to apply to the filter conditions.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// If all of the conditions evaluate to true, then the entire filter evaluates to true.
+ ///
+ ///
+ ///
+ /// If at least one of the conditions evaluate to true, then the entire filter evaluates to true.
+ ///
+ ///
+ /// The default value is .
+ ///
+ public ConditionalOperatorValues ConditionalOperator { get; set; }
+
+ ///
+ /// Filter for the Scan operation. Evaluates the query results and returns only
+ /// the matching values. If you specify more than one condition, then by default all of the
+ /// conditions must evaluate to true. To match only some conditions, set to .
+ ///
+ ///
+ /// Note: Conditions must be against non-key properties.
+ ///
+ public List QueryFilter { get; set; }
+
+ ///
+ /// Property that directs to use consistent reads.
+ /// If property is not set, behavior defaults to non-consistent reads.
+ ///
+ ///
+ /// Refer to the
+ /// Read Consistency topic in the DynamoDB Developer Guide for more information.
+ ///
+ public bool? ConsistentRead { get; set; }
+
+ ///
+ /// If true, all properties are retrieved in UTC timezone while reading data from DynamoDB. Else, the local timezone is used.
+ ///
+ ///
+ /// This setting is only applicable to the high-level library. Service calls made via
+ /// will always return attributes in UTC.
+ ///
+ public bool? RetrieveDateTimeInUtc { get; set; }
+
+ ///
+ internal override DynamoDBOperationConfig ToDynamoDBOperationConfig()
+ {
+ var config = base.ToDynamoDBOperationConfig();
+ config.IndexName = IndexName;
+ config.ConditionalOperator = ConditionalOperator;
+ config.QueryFilter = QueryFilter;
+ config.ConsistentRead = ConsistentRead;
+ config.RetrieveDateTimeInUtc = RetrieveDateTimeInUtc;
+
+ return config;
+ }
+ }
+}
diff --git a/sdk/src/Services/DynamoDBv2/Custom/DataModel/_async/Context.Async.cs b/sdk/src/Services/DynamoDBv2/Custom/DataModel/_async/Context.Async.cs
index 36f2b19ae108..0ae0a86a92dc 100644
--- a/sdk/src/Services/DynamoDBv2/Custom/DataModel/_async/Context.Async.cs
+++ b/sdk/src/Services/DynamoDBv2/Custom/DataModel/_async/Context.Async.cs
@@ -339,30 +339,39 @@ public Task ExecuteBatchGetAsync(params BatchGet[] batches)
#region Scan async
- ///
- /// Configures an async Scan operation against DynamoDB, finding items
- /// that match the specified conditions.
- ///
- /// Type of object.
- ///
- /// Conditions that the results should meet.
- ///
- /// Config object which can be used to override that table used.
- /// AsyncSearch which can be used to retrieve DynamoDB data.
+ ///
+ public AsyncSearch ScanAsync(IEnumerable conditions)
+ {
+ var scan = ConvertScan(conditions, null);
+ return FromSearchAsync(scan);
+ }
+
+ ///
+ [Obsolete("Use the ScanAsync overload that takes ScanConfig instead, since DynamoDBOperationConfig contains properties that are not applicable to ScanAsync.")]
public AsyncSearch ScanAsync(IEnumerable conditions, DynamoDBOperationConfig operationConfig = null)
{
var scan = ConvertScan(conditions, operationConfig);
return FromSearchAsync(scan);
}
- ///
- /// Configures an async Scan operation against DynamoDB, finding items
- /// that match the specified conditions.
- ///
- /// Type of object.
- /// Scan request object.
- /// Config object which can be used to override the table used.
- /// AsyncSearch which can be used to retrieve DynamoDB data.
+ ///
+ public AsyncSearch ScanAsync(IEnumerable conditions, ScanConfig scanConfig)
+ {
+ var scan = ConvertScan(conditions, scanConfig?.ToDynamoDBOperationConfig());
+ return FromSearchAsync(scan);
+ }
+
+ ///
+ public AsyncSearch FromScanAsync(ScanOperationConfig scanConfig)
+ {
+ if (scanConfig == null) throw new ArgumentNullException("scanConfig");
+
+ var search = ConvertFromScan(scanConfig, null);
+ return FromSearchAsync(search);
+ }
+
+ ///
+ [Obsolete("Use the FromScanAsync overload that takes ScanConfig instead, since DynamoDBOperationConfig contains properties that are not applicable to FromScanAsync.")]
public AsyncSearch FromScanAsync(ScanOperationConfig scanConfig, DynamoDBOperationConfig operationConfig = null)
{
if (scanConfig == null) throw new ArgumentNullException("scanConfig");
@@ -371,38 +380,53 @@ public AsyncSearch FromScanAsync(ScanOperationConfig scanConfig, DynamoDBO
return FromSearchAsync(search);
}
+ ///
+ public AsyncSearch FromScanAsync(ScanOperationConfig scanConfig, FromScanConfig fromScanConfig)
+ {
+ if (scanConfig == null) throw new ArgumentNullException("scanConfig");
+
+ var search = ConvertFromScan(scanConfig, fromScanConfig?.ToDynamoDBOperationConfig());
+ return FromSearchAsync(search);
+ }
+
#endregion
#region Query async
- ///
- /// Configures an async Query operation against DynamoDB, finding items
- /// that match the specified hash primary key.
- ///
- /// Type of object.
- /// Hash key of the items to query.
- /// Config object which can be used to override the table used.
- /// AsyncSearch which can be used to retrieve DynamoDB data.
+ ///
+ public AsyncSearch QueryAsync(object hashKeyValue)
+ {
+ var query = ConvertQueryByValue(hashKeyValue, null, null);
+ return FromSearchAsync(query);
+ }
+
+ ///
+ [Obsolete("Use the QueryAsync overload that takes QueryConfig instead, since DynamoDBOperationConfig contains properties that are not applicable to QueryAsync.")]
public AsyncSearch QueryAsync(object hashKeyValue, DynamoDBOperationConfig operationConfig = null)
{
var query = ConvertQueryByValue(hashKeyValue, null, operationConfig);
return FromSearchAsync(query);
}
- ///
- /// Configures an async Query operation against DynamoDB, finding items
- /// that match the specified range element condition for a hash-and-range primary key.
- ///
- /// Type of object.
- /// Hash key of the items to query.
- /// Operation of the condition.
- ///
- /// Value(s) of the condition.
- /// For all operations except QueryOperator.Between, values should be one value.
- /// For QueryOperator.Between, values should be two values.
- ///
- /// Config object which can be used to override the table used.
- /// AsyncSearch which can be used to retrieve DynamoDB data.
+ ///
+ public AsyncSearch QueryAsync(object hashKeyValue, QueryConfig queryConfig)
+ {
+ var query = ConvertQueryByValue(hashKeyValue, null, queryConfig?.ToDynamoDBOperationConfig());
+ return FromSearchAsync(query);
+ }
+
+ ///
+ public AsyncSearch QueryAsync(object hashKeyValue, QueryOperator op, IEnumerable