private IEnumerable <T> FromSearch <T>(ContextSearch cs)
        {
            if (cs == null)
            {
                throw new ArgumentNullException("cs");
            }

            // Configure search to not collect results
            cs.Search.CollectResults = false;

            ItemStorageConfig storageConfig = StorageConfigCache.GetConfig <T>(cs.FlatConfig);

            while (!cs.Search.IsDone)
            {
                List <Document> set = cs.Search.GetNextSetHelper(false);
                foreach (var document in set)
                {
                    ItemStorage storage = new ItemStorage(storageConfig);
                    storage.Document = document;
                    T instance = DocumentToObject <T>(storage, cs.FlatConfig);
                    yield return(instance);
                }
            }

            // Reset search to allow retrieving items more than once
            cs.Search.Reset();
        }
        private ContextSearch ConvertQueryByValue <T>(object hashKeyValue, QueryOperator op, IEnumerable <object> values, DynamoDBOperationConfig operationConfig)
        {
            DynamoDBFlatConfig    flatConfig    = new DynamoDBFlatConfig(operationConfig, Config);
            ItemStorageConfig     storageConfig = StorageConfigCache.GetConfig <T>(flatConfig);
            List <QueryCondition> conditions    = CreateQueryConditions(flatConfig, op, values, storageConfig);
            ContextSearch         query         = ConvertQueryByValue <T>(hashKeyValue, conditions, operationConfig, storageConfig);

            return(query);
        }
        /// <summary>
        /// Configures an async Query operation against DynamoDB, finding items
        /// that match the specified range element condition for a hash-and-range primary key.
        /// </summary>
        /// <typeparam name="T">Type of object.</typeparam>
        /// <param name="hashKeyValue">Hash key of the items to query.</param>
        /// <param name="op">Operation of the condition.</param>
        /// <param name="values">
        /// Value(s) of the condition.
        /// For all operations except QueryOperator.Between, values should be one value.
        /// For QueryOperator.Between, values should be two values.
        /// </param>
        /// <param name="operationConfig">Config object which can be used to override the table used.</param>
        /// <returns>AsyncSearch which can be used to retrieve DynamoDB data.</returns>
        public AsyncSearch <T> QueryAsync <T>(object hashKeyValue, QueryOperator op, IEnumerable <object> values, DynamoDBOperationConfig operationConfig)
        {
            if (values == null)
            {
                throw new ArgumentNullException("values");
            }

            ContextSearch query = ConvertQueryByValue <T>(hashKeyValue, op, values, operationConfig);

            return(FromSearchAsync <T>(query));
        }
Beispiel #4
0
 /// <summary>
 /// Configures an async Query operation against DynamoDB, finding items
 /// that match the specified hash primary key.
 /// </summary>
 /// <typeparam name="T">Type of object.</typeparam>
 /// <param name="hashKeyValue">Hash key of the items to query.</param>
 /// <param name="operationConfig">Config object which can be used to override the table used.</param>
 /// <param name="callback">The callback that will be invoked when the asynchronous operation completes.</param>
 /// <param name="asyncOptions">An instance of AsyncOptions that specifies how the async method should be executed.</param>
 public void QueryAsync <T>(object hashKeyValue, DynamoDBOperationConfig operationConfig, AmazonDynamoDBCallback <AsyncSearch <T> > callback, AsyncOptions asyncOptions = null)
 {
     asyncOptions = asyncOptions ?? new AsyncOptions();
     DynamoDBAsyncExecutor.ExecuteAsync <AsyncSearch <T> >(
         () =>
     {
         ContextSearch query = ConvertQueryByValue <T>(hashKeyValue, null, operationConfig);
         return(FromSearchAsync <T>(query));
     },
         asyncOptions,
         callback);
 }
Beispiel #5
0
        /// <summary>
        /// Configures an async Query operation against DynamoDB, finding items
        /// that match the specified range element condition for a hash-and-range primary key.
        /// </summary>
        /// <typeparam name="T">Type of object.</typeparam>
        /// <param name="hashKeyValue">Hash key of the items to query.</param>
        /// <param name="op">Operation of the condition.</param>
        /// <param name="values">
        /// Value(s) of the condition.
        /// For all operations except QueryOperator.Between, values should be one value.
        /// For QueryOperator.Between, values should be two values.
        /// </param>
        /// <param name="operationConfig">Config object which can be used to override the table used.</param>
        /// <param name="callback">The callback that will be invoked when the asynchronous operation completes.</param>
        /// <param name="asyncOptions">An instance of AsyncOptions that specifies how the async method should be executed.</param>
        public void QueryAsync <T>(object hashKeyValue, QueryOperator op, IEnumerable <object> values, DynamoDBOperationConfig operationConfig, AmazonDynamoDBCallback <AsyncSearch <T> > callback, AsyncOptions asyncOptions = null)
        {
            asyncOptions = asyncOptions ?? new AsyncOptions();
            DynamoDBAsyncExecutor.ExecuteAsync <AsyncSearch <T> >(
                () =>
            {
                if (values == null)
                {
                    throw new ArgumentNullException("values");
                }

                ContextSearch query = ConvertQueryByValue <T>(hashKeyValue, op, values, operationConfig);
                return(FromSearchAsync <T>(query));
            },
                asyncOptions,
                callback);
        }
        /// <summary>
        /// Configures an async Query operation against DynamoDB, finding items
        /// that match the specified hash primary key.
        /// </summary>
        /// <typeparam name="T">Type of object.</typeparam>
        /// <param name="hashKeyValue">Hash key of the items to query.</param>
        /// <param name="operationConfig">Config object which can be used to override the table used.</param>
        /// <returns>AsyncSearch which can be used to retrieve DynamoDB data.</returns>
        public AsyncSearch <T> QueryAsync <T>(object hashKeyValue, DynamoDBOperationConfig operationConfig)
        {
            ContextSearch query = ConvertQueryByValue <T>(hashKeyValue, null, operationConfig);

            return(FromSearchAsync <T>(query));
        }
 private AsyncSearch <T> FromSearchAsync <T>(ContextSearch contextSearch)
 {
     return(new AsyncSearch <T>(this, contextSearch));
 }