示例#1
0
        internal Document GetItemHelper(Key key, GetItemOperationConfig config, bool isAsync)
        {
            var currentConfig = config ?? new GetItemOperationConfig();
            var request = new GetItemRequest
            {
                TableName = TableName,
                Key = key,
                ConsistentRead = currentConfig.ConsistentRead
            };
            request.BeforeRequestEvent += isAsync ?
                new RequestEventHandler(UserAgentRequestEventHandlerAsync) :
                new RequestEventHandler(UserAgentRequestEventHandlerSync);
            if (currentConfig.AttributesToGet != null)
                request.WithAttributesToGet(currentConfig.AttributesToGet);

            var result = DDBClient.GetItem(request);
            var attributeMap = result.GetItemResult.Item;
            if (attributeMap == null)
                return null;
            return Document.FromAttributeMap(attributeMap);
        }
示例#2
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetItem operation.
 /// <seealso cref="Amazon.DynamoDB.DocumentModel.Table.GetItem"/>
 /// </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>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetItem
 ///         operation.</returns>
 public IAsyncResult BeginGetItem(Primitive hashKey, Primitive rangeKey, GetItemOperationConfig config, AsyncCallback callback, object state)
 {
     return DynamoDBAsyncExecutor.BeginOperation(() => GetItemHelper(MakeKey(hashKey, rangeKey), config, true), callback, state);
 }
示例#3
0
 /// <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>
 public Document GetItem(Primitive hashKey, Primitive rangeKey, GetItemOperationConfig config)
 {
     return GetItemHelper(MakeKey(hashKey, rangeKey), config, false);
 }
示例#4
0
 /// <summary>
 /// Gets a document from DynamoDB by 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>Document from DynamoDB.</returns>
 public Document GetItem(Primitive hashKey, GetItemOperationConfig config)
 {
     return GetHelper(MakeKey(hashKey, null), config);
 }