|
| 1 | +/* |
| 2 | + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"). |
| 5 | + * You may not use this file except in compliance with the License. |
| 6 | + * A copy of the License is located at |
| 7 | + * |
| 8 | + * http://aws.amazon.com/apache2.0 |
| 9 | + * |
| 10 | + * or in the "license" file accompanying this file. This file is distributed |
| 11 | + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 12 | + * express or implied. See the License for the specific language governing |
| 13 | + * permissions and limitations under the License. |
| 14 | + */ |
| 15 | + |
| 16 | +using Amazon.DynamoDBv2.DocumentModel; |
| 17 | +using System; |
| 18 | +using System.Collections.Generic; |
| 19 | + |
| 20 | +namespace Amazon.DynamoDBv2.DataModel |
| 21 | +{ |
| 22 | + /// <summary> |
| 23 | + /// Input for the Query operation in the object-persistence programming model |
| 24 | + /// </summary> |
| 25 | +#if NET8_0_OR_GREATER |
| 26 | + // The DataModel namespace doesn't support trimming yet, so annotate public classes/methods as incompatible |
| 27 | + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode(Custom.Internal.InternalConstants.RequiresUnreferencedCodeMessage)] |
| 28 | +#endif |
| 29 | + public class QueryConfig : BaseOperationConfig |
| 30 | + { |
| 31 | + /// <summary> |
| 32 | + /// Indicates whether a query should traverse the index backwards in descending order by range key value. |
| 33 | + /// If the property is false (or not set), traversal shall be in ascending order. |
| 34 | + /// </summary> |
| 35 | + public bool? BackwardQuery { get; set; } |
| 36 | + |
| 37 | + /// <summary> |
| 38 | + /// Indicates the name of the index to query against. |
| 39 | + /// This value is optional if the index name can be inferred from the call. |
| 40 | + /// </summary> |
| 41 | + public string IndexName { get; set; } |
| 42 | + |
| 43 | + /// <summary> |
| 44 | + /// The logical operator to apply to the filter conditions. |
| 45 | + /// </summary> |
| 46 | + /// <remarks> |
| 47 | + /// <list type="bullet"> |
| 48 | + /// <item> |
| 49 | + /// <term><see cref="ConditionalOperatorValues.And" /></term> |
| 50 | + /// <definition>If all of the conditions evaluate to true, then the entire filter evaluates to true.</definition> |
| 51 | + /// </item> |
| 52 | + /// <item> |
| 53 | + /// <term><see cref="ConditionalOperatorValues.Or" /></term> |
| 54 | + /// <definition>If at least one of the conditions evaluate to true, then the entire filter evaluates to true.</definition> |
| 55 | + /// </item> |
| 56 | + /// </list> |
| 57 | + /// The default value is <see cref="ConditionalOperatorValues.And" />. |
| 58 | + /// </remarks> |
| 59 | + public ConditionalOperatorValues ConditionalOperator { get; set; } |
| 60 | + |
| 61 | + /// <summary> |
| 62 | + /// Query filter for the Query operation. Evaluates the query results and returns only |
| 63 | + /// the matching values. If you specify more than one condition, then by default all of the |
| 64 | + /// conditions must evaluate to true. To match only some conditions, set <see cref="ConditionalOperator"/> to <see cref="ConditionalOperatorValues.Or" />. |
| 65 | + /// </summary> |
| 66 | + /// <remarks> |
| 67 | + /// Note: Conditions must be against non-key properties. |
| 68 | + /// </remarks> |
| 69 | + public List<ScanCondition> QueryFilter { get; set; } |
| 70 | + |
| 71 | + /// <summary> |
| 72 | + /// Property that directs <see cref="DynamoDBContext" /> to use consistent reads. |
| 73 | + /// If property is not set, behavior defaults to non-consistent reads. |
| 74 | + /// </summary> |
| 75 | + /// <remarks> |
| 76 | + /// Refer to the <see href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadConsistency.html"> |
| 77 | + /// Read Consistency</see> topic in the DynamoDB Developer Guide for more information. |
| 78 | + /// </remarks> |
| 79 | + public bool? ConsistentRead { get; set; } |
| 80 | + |
| 81 | + /// <summary> |
| 82 | + /// If true, all <see cref="DateTime"/> properties are retrieved in UTC timezone while reading data from DynamoDB. Else, the local timezone is used. |
| 83 | + /// </summary> |
| 84 | + /// <remarks> |
| 85 | + /// This setting is only applicable to the high-level library. Service calls made via |
| 86 | + /// <see cref="AmazonDynamoDBClient"/> will always return <see cref="DateTime"/> attributes in UTC. |
| 87 | + /// </remarks> |
| 88 | + public bool? RetrieveDateTimeInUtc { get; set; } |
| 89 | + |
| 90 | + /// <inheritdoc/> |
| 91 | + internal override DynamoDBOperationConfig ToDynamoDBOperationConfig() |
| 92 | + { |
| 93 | + var config = base.ToDynamoDBOperationConfig(); |
| 94 | + config.BackwardQuery = BackwardQuery; |
| 95 | + config.IndexName = IndexName; |
| 96 | + config.ConditionalOperator = ConditionalOperator; |
| 97 | + config.QueryFilter = QueryFilter; |
| 98 | + config.ConsistentRead = ConsistentRead; |
| 99 | + config.RetrieveDateTimeInUtc = RetrieveDateTimeInUtc; |
| 100 | + |
| 101 | + return config; |
| 102 | + } |
| 103 | + } |
| 104 | +} |
0 commit comments