GetItemAsync() public method

Initiates the asynchronous execution of the GetItem operation.
public GetItemAsync ( DynamoDBEntry>.IDictionary key, AmazonDynamoDBCallback callback, AsyncOptions asyncOptions = null ) : void
key DynamoDBEntry>.IDictionary Key of the document.
callback AmazonDynamoDBCallback The callback that will be invoked when the asynchronous operation completes.
asyncOptions Amazon.Runtime.AsyncOptions An instance of AsyncOptions that specifies how the async method should be executed.
return void
        /// <summary>
        /// Gets a resource of a given type and with the provided id from a given table
        /// </summary>
        /// <param name="table"></param>
        /// <param name="typeName"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        private async Task <dynamic> Get(DynamoDbTable table, string typeName, string id)
        {
            var hashKey  = new Primitive($"{typeName}");
            var rangeKey = new Primitive(id);

            Logger.Debug("Getting item with hash key {0} and range key {1} from table {2}...", hashKey, rangeKey, table.TableName);

            var result = await table.GetItemAsync(hashKey, rangeKey);

            return(result != null?DynamoDbDocumentHelper.ToObject(result) : null);
        }
Exemplo n.º 2
0
        private async Task<string> ReadData(Table table, string id)
        {
            Document doc = await table.GetItemAsync(new Primitive(id));

            var body = doc["Body"];
            return body;
        }