/// <summary>
        /// Executes a 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>Lazy-loaded collection of results.</returns>
        internal IEnumerable <T> Query <T>(object hashKeyValue, DynamoDBOperationConfig operationConfig)
        {
            DynamoDBAsyncExecutor.IsMainThread("QueryAsync");
            var query = ConvertQueryByValue <T>(hashKeyValue, null, operationConfig);

            return(FromSearch <T>(query));
        }
        /// <summary>
        /// Issues a batch-write request with multiple batches.
        /// </summary>
        /// <param name="batches">
        /// Configured BatchWrite objects
        /// </param>
        internal void ExecuteBatchWrite(params BatchWrite[] batches)
        {
            DynamoDBAsyncExecutor.IsMainThread("ExecuteBatchWriteAsync");
            MultiTableBatchWrite superBatch = new MultiTableBatchWrite(batches);

            superBatch.Execute();
        }
Example #3
0
        internal static Table LoadTable(IAmazonDynamoDB ddbClient, string tableName, Table.DynamoDBConsumer consumer)
        {
            DynamoDBAsyncExecutor.IsMainThread("LoadTableAsync");
            Table table = new Table(ddbClient, tableName, consumer);

            table.GetTableInfo();
            return(table);
        }
        /// <summary>
        /// Executes a Scan operation against DynamoDB, finding items
        /// that match the specified conditions.
        /// </summary>
        /// <typeparam name="T">Type of object.</typeparam>
        /// <param name="conditions">
        /// Conditions that the results should meet.
        /// </param>
        /// <returns>Lazy-loaded collection of results.</returns>
        internal IEnumerable <T> Scan <T>(params ScanCondition[] conditions)
        {
            DynamoDBAsyncExecutor.IsMainThread("ScanAsync");
            if (conditions == null)
            {
                throw new ArgumentNullException("conditions");
            }

            return(Scan <T>(conditions, null));
        }
        /// <summary>
        /// Executes a 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>
        /// <returns>Lazy-loaded collection of results.</returns>
        internal IEnumerable <T> Query <T>(object hashKeyValue, QueryOperator op, params object[] values)
        {
            DynamoDBAsyncExecutor.IsMainThread("QueryAsync");
            if (values == null || values.Length == 0)
            {
                throw new ArgumentOutOfRangeException("values");
            }

            return(Query <T>(hashKeyValue, op, values, null));
        }
        /// <summary>
        /// Executes a Query operation against DynamoDB, finding items
        /// that match the specified conditions.
        /// </summary>
        /// <typeparam name="T">Type of object.</typeparam>
        /// <param name="queryConfig">Query request object.</param>
        /// <param name="operationConfig">Config object which can be used to override the table used.</param>
        /// <returns>Lazy-loaded collection of results.</returns>
        internal IEnumerable <T> FromQuery <T>(QueryOperationConfig queryConfig, DynamoDBOperationConfig operationConfig)
        {
            DynamoDBAsyncExecutor.IsMainThread("FromQueryAsync");
            if (queryConfig == null)
            {
                throw new ArgumentNullException("queryConfig");
            }

            var search = ConvertFromQuery <T>(queryConfig, operationConfig);

            return(FromSearch <T>(search));
        }
        /// <summary>
        /// Executes a 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>Lazy-loaded collection of results.</returns>
        internal IEnumerable <T> Query <T>(object hashKeyValue, QueryOperator op, IEnumerable <object> values, DynamoDBOperationConfig operationConfig)
        {
            DynamoDBAsyncExecutor.IsMainThread("QueryAsync");
            if (values == null)
            {
                throw new ArgumentNullException("values");
            }

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

            return(FromSearch <T>(query));
        }
        /// <summary>
        /// Executes a Scan operation against DynamoDB, finding items
        /// that match the specified conditions.
        /// </summary>
        /// <typeparam name="T">Type of object.</typeparam>
        /// <param name="scanConfig">Scan request object.</param>
        /// <param name="operationConfig">Config object which can be used to override the table used.</param>
        /// <returns>Lazy-loaded collection of results.</returns>
        internal IEnumerable <T> FromScan <T>(ScanOperationConfig scanConfig, DynamoDBOperationConfig operationConfig)
        {
            DynamoDBAsyncExecutor.IsMainThread("FromScanAsync");
            if (scanConfig == null)
            {
                throw new ArgumentNullException("scanConfig");
            }

            var scan = ConvertFromScan <T>(scanConfig, operationConfig);

            return(FromSearch <T>(scan));
        }
        /// <summary>
        /// Executes a Scan operation against DynamoDB, finding items
        /// that match the specified conditions.
        /// </summary>
        /// <typeparam name="T">Type of object.</typeparam>
        /// <param name="conditions">
        /// Conditions that the results should meet.
        /// </param>
        /// <param name="operationConfig">Config object which can be used to override the table used.</param>
        /// <returns>Lazy-loaded collection of results.</returns>
        internal IEnumerable <T> Scan <T>(IEnumerable <ScanCondition> conditions, DynamoDBOperationConfig operationConfig)
        {
            DynamoDBAsyncExecutor.IsMainThread("ScanAsync");
            if (conditions == null)
            {
                throw new ArgumentNullException("conditions");
            }

            var scan = ConvertScan <T>(conditions, operationConfig);

            return(FromSearch <T>(scan));
        }
Example #10
0
 /// <summary>
 /// Creates a Table object with the specified name, using the
 /// passed-in client to load the table definition.
 ///
 /// This method will return false if the table does not exist.
 /// </summary>
 /// <param name="ddbClient">Client to use to access DynamoDB.</param>
 /// <param name="tableName">Name of the table.</param>
 /// <param name="table">Loaded table.</param>
 /// <returns>
 /// True if table was successfully loaded; otherwise false.
 /// </returns>
 internal static bool TryLoadTable(IAmazonDynamoDB ddbClient, string tableName, out Table table)
 {
     DynamoDBAsyncExecutor.IsMainThread("LoadTableAsync");
     try
     {
         table = LoadTable(ddbClient, tableName);
         return(true);
     }
     catch
     {
         table = null;
         return(false);
     }
 }
 /// <summary>
 /// Delete a document in DynamoDB.
 /// </summary>
 /// <param name="document">Document to delete.</param>
 internal void DeleteItem(Document document)
 {
     DynamoDBAsyncExecutor.IsMainThread("DeleteItemAsync");
     DeleteHelper(MakeKey(document), null, false);
 }
 /// <summary>
 /// Update a document in DynamoDB, with a key to identify the
 /// document, and using the specified config.
 /// </summary>
 /// <param name="doc">Attributes to update.</param>
 /// <param name="key">Key of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Null or updated attributes, depending on config.</returns>
 /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.UpdateItemOperationConfig"/>
 internal Document UpdateItem(Document doc, IDictionary <string, DynamoDBEntry> key, UpdateItemOperationConfig config)
 {
     DynamoDBAsyncExecutor.IsMainThread("UpdateItemAsync");
     return(UpdateHelper(doc, MakeKey(key), config, false));
 }
 /// <summary>
 /// Update a document in DynamoDB, with a hash-and-range primary key to identify
 /// the document, and using the specified config.
 /// </summary>
 /// <param name="doc">Attributes to update.</param>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="rangeKey">Range key element of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Null or updated attributes, depending on config.</returns>
 /// <seealso cref="Amazon.DynamoDBv2.DocumentModel.UpdateItemOperationConfig"/>
 internal Document UpdateItem(Document doc, Primitive hashKey, Primitive rangeKey, UpdateItemOperationConfig config)
 {
     DynamoDBAsyncExecutor.IsMainThread("UpdateItemAsync");
     return(UpdateHelper(doc, MakeKey(hashKey, rangeKey), config, false));
 }
 /// <summary>
 /// Loads an object from DynamoDB for the given hash primary key and using the given config.
 ///
 /// Passed-in config overrides DynamoDBContextConfig on the context.
 /// Type must be marked up with DynamoDBTableAttribute and at least
 /// one public field/property with DynamoDBHashKeyAttribute.
 /// </summary>
 /// <typeparam name="T">Type to populate.</typeparam>
 /// <param name="hashKey">Hash key element of the target item.</param>
 /// <param name="operationConfig">Overriding configuration.</param>
 /// <returns>
 /// Object of type T, populated with properties of item loaded from DynamoDB.
 /// </returns>
 internal T Load <T>(object hashKey, DynamoDBOperationConfig operationConfig)
 {
     DynamoDBAsyncExecutor.IsMainThread("LoadAsync");
     return(Load <T>(hashKey, null, operationConfig));
 }
 /// <summary>
 /// Update a document in DynamoDB, with a hash-and-range primary key
 /// to identify the document.
 /// </summary>
 /// <param name="doc">Attributes to update.</param>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="rangeKey">Range key element of the document.</param>
 internal void UpdateItem(Document doc, Primitive hashKey, Primitive rangeKey)
 {
     DynamoDBAsyncExecutor.IsMainThread("UpdateItemAsync");
     UpdateHelper(doc, MakeKey(hashKey, rangeKey), null, false);
 }
 /// <summary>
 /// Gets a document from DynamoDB by hash-and-range primary key,
 /// using specified configs.
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="rangeKey">Range key element of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Document from DynamoDB.</returns>
 internal Document GetItem(Primitive hashKey, Primitive rangeKey, GetItemOperationConfig config)
 {
     DynamoDBAsyncExecutor.IsMainThread("GetItemAsync");
     return(GetItemHelper(MakeKey(hashKey, rangeKey), config, false));
 }
 /// <summary>
 /// Puts a document into DynamoDB, using specified configs.
 /// </summary>
 /// <param name="doc">Document to save.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Null or updated attributes, depending on config.</returns>
 internal Document PutItem(Document doc, PutItemOperationConfig config)
 {
     DynamoDBAsyncExecutor.IsMainThread("PutItemAsync");
     return(PutItemHelper(doc, config, false));
 }
 /// <summary>
 /// Puts a document into DynamoDB.
 /// </summary>
 /// <param name="doc">Document to save.</param>
 internal void PutItem(Document doc)
 {
     DynamoDBAsyncExecutor.IsMainThread("PutItemAsync");
     PutItem(doc, null);
 }
 /// <summary>
 /// Delete a document in DynamoDB, using specified configs.
 /// </summary>
 /// <param name="document">Document to delete.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Null or old attributes, depending on config.</returns>
 internal Document DeleteItem(Document document, DeleteItemOperationConfig config)
 {
     DynamoDBAsyncExecutor.IsMainThread("DeleteItemAsync");
     return(DeleteHelper(MakeKey(document), config, false));
 }
 /// <summary>
 /// Delete a document in DynamoDB, identified by a hash-and-range primary key.
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="rangeKey">Range key element of the document.</param>
 internal void DeleteItem(Primitive hashKey, Primitive rangeKey)
 {
     DynamoDBAsyncExecutor.IsMainThread("DeleteItemAsync");
     DeleteHelper(MakeKey(hashKey, rangeKey), null, false);
 }
 /// <summary>
 /// Delete a document in DynamoDB, identified by a key.
 /// </summary>
 /// <param name="key">Hash key element of the document.</param>
 internal void DeleteItem(IDictionary <string, DynamoDBEntry> key)
 {
     DynamoDBAsyncExecutor.IsMainThread("DeleteItemAsync");
     DeleteHelper(MakeKey(key), null, false);
 }
 /// <summary>
 /// Retrieves the next set (page) of results
 /// </summary>
 /// <returns>Next set of Documents matching the search parameters</returns>
 internal List <Document> GetNextSet()
 {
     DynamoDBAsyncExecutor.IsMainThread("GetNextSetAsync");
     return(GetNextSetHelper(false));
 }
 /// <summary>
 /// Delete a document in DynamoDB, identified by a hash primary key,
 /// using specified configs.
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Null or old attributes, depending on config.</returns>
 internal Document DeleteItem(Primitive hashKey, DeleteItemOperationConfig config)
 {
     DynamoDBAsyncExecutor.IsMainThread("DeleteItemAsync");
     return(DeleteHelper(MakeKey(hashKey, null), config, false));
 }
 /// <summary>
 /// Retrieves all the remaining results
 /// </summary>
 /// <returns>List of Documents matching the search parameters</returns>
 internal List <Document> GetRemaining()
 {
     DynamoDBAsyncExecutor.IsMainThread("GetRemaining");
     return(GetRemainingHelper(false));
 }
 /// <summary>
 /// Delete a document in DynamoDB, identified by a key, using specified configs.
 /// </summary>
 /// <param name="key">Key of the document.</param>
 /// <param name="config">Configuration to use.</param>
 /// <returns>Null or old attributes, depending on config.</returns>
 internal Document DeleteItem(IDictionary <string, DynamoDBEntry> key, DeleteItemOperationConfig config)
 {
     DynamoDBAsyncExecutor.IsMainThread("DeleteItemAsync");
     return(DeleteHelper(MakeKey(key), config, false));
 }
 /// <summary>
 /// Gets a document from DynamoDB by key.
 /// </summary>
 /// <param name="key">Values that make up the key of the document.</param>
 /// <returns>Document from DynamoDB</returns>
 internal Document GetItem(IDictionary <string, DynamoDBEntry> key)
 {
     DynamoDBAsyncExecutor.IsMainThread("GetItemAsync");
     return(GetItemHelper(MakeKey(key), null, false));
 }
 /// <summary>
 /// Gets a document from DynamoDB by hash primary key.
 /// </summary>
 /// <param name="hashKey">Hash key element of the document.</param>
 /// <returns>Document from DynamoDB</returns>
 internal Document GetItem(Primitive hashKey)
 {
     DynamoDBAsyncExecutor.IsMainThread("GetItemAsync");
     return(GetItemHelper(MakeKey(hashKey, null), null, false));
 }
 /// <summary>
 /// Update a document in DynamoDB.
 /// </summary>
 /// <param name="doc">Document to update.</param>
 internal void UpdateItem(Document doc)
 {
     DynamoDBAsyncExecutor.IsMainThread("UpdateItemAsync");
     UpdateHelper(doc, MakeKey(doc), null, false);
 }
 /// <summary>
 /// Executes a multi-table batch put/delete against all configured batches.
 ///
 /// If more than 25 put/delete operations are specified, calls of up to 25
 /// put/delete items will be made until all items are processed.
 /// </summary>
 internal void Execute()
 {
     DynamoDBAsyncExecutor.IsMainThread("ExecuteAsync");
     ExecuteHelper(false);
 }
 /// <summary>
 /// Update a document in DynamoDB, with key to identify the document.
 /// </summary>
 /// <param name="doc">Attributes to update.</param>
 /// <param name="key">Key of the document.</param>
 internal void UpdateItem(Document doc, IDictionary <string, DynamoDBEntry> key)
 {
     DynamoDBAsyncExecutor.IsMainThread("UpdateItemAsync");
     UpdateHelper(doc, MakeKey(key), null, false);
 }