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); }
public Hashtable GetItem(Hashtable State, string tableName, string PrimaryKeyValue) { if (State["DynamoDBClient"] == null) SetupClient(State); AmazonDynamoDB client = (AmazonDynamoDB)State["DynamoDBClient"]; var request = new GetItemRequest { TableName = tableName, Key = new Key { HashKeyElement = new AttributeValue { S = PrimaryKeyValue } }, ConsistentRead = true }; var response = client.GetItem(request); // Check the response. var result = response.GetItemResult; var attributeList = result.Item; // attribute list in the response. Hashtable map = new Hashtable(); if (attributeList != null) { foreach (KeyValuePair<string, AttributeValue> kvp in attributeList) { string attributeName = kvp.Key; AttributeValue value = kvp.Value; map[attributeName] = value.S; } } return map; }
IAsyncResult invokeGetItem(GetItemRequest getItemRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new GetItemRequestMarshaller().Marshall(getItemRequest); var unmarshaller = GetItemResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
/// <summary> /// <para>Retrieves a set of Attributes for an item that matches the primary key.</para> <para>The <c>GetItem</c> operation provides an /// eventually-consistent read by default. If eventually-consistent reads are not acceptable for your application, use <c>ConsistentRead</c> . /// Although this operation might take longer than a standard read, it always returns the last updated value.</para> /// </summary> /// /// <param name="getItemRequest">Container for the necessary parameters to execute the GetItem service method on AmazonDynamoDB.</param> /// /// <returns>The response from the GetItem service method, as returned by AmazonDynamoDB.</returns> /// /// <exception cref="ProvisionedThroughputExceededException"/> /// <exception cref="InternalServerErrorException"/> /// <exception cref="ResourceNotFoundException"/> public GetItemResponse GetItem(GetItemRequest getItemRequest) { IAsyncResult asyncResult = invokeGetItem(getItemRequest, null, null, true); return EndGetItem(asyncResult); }
/// <summary> /// Initiates the asynchronous execution of the GetItem operation. /// <seealso cref="Amazon.DynamoDB.AmazonDynamoDB.GetItem"/> /// </summary> /// /// <param name="getItemRequest">Container for the necessary parameters to execute the GetItem operation on AmazonDynamoDB.</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(GetItemRequest getItemRequest, AsyncCallback callback, object state) { return invokeGetItem(getItemRequest, callback, state, false); }
/// <summary> /// <para> The GetItem operation returns a set of Attributes for an item that matches the primary key. The GetItem operation provides an /// eventually consistent read by default. If eventually consistent reads are not acceptable for your application, use ConsistentRead. Although /// this operation might take longer than a standard read, it always returns the last updated value. </para> /// </summary> /// /// <param name="getItemRequest">Container for the necessary parameters to execute the GetItem service method on AmazonDynamoDB.</param> /// /// <returns>The response from the GetItem service method, as returned by AmazonDynamoDB.</returns> /// /// <exception cref="ProvisionedThroughputExceededException"/> /// <exception cref="InternalServerErrorException"/> /// <exception cref="ResourceNotFoundException"/> public GetItemResponse GetItem(GetItemRequest getItemRequest) { IRequest<GetItemRequest> request = new GetItemRequestMarshaller().Marshall(getItemRequest); GetItemResponse response = Invoke<GetItemRequest, GetItemResponse> (request, this.signer, GetItemResponseUnmarshaller.GetInstance()); return response; }