Amazon.DynamoDBv2.AmazonDynamoDBClient.GetItem C# (CSharp) Méthode

GetItem() public méthode

The GetItem operation returns a set of attributes for the item with the given primary key. If there is no matching item, GetItem does not return any data.

GetItem provides an eventually consistent read by default. If your application requires a strongly consistent read, set ConsistentRead to true. Although a strongly consistent read might take more time than an eventually consistent read, it always returns the last updated value.

/// An error occurred on the server side. /// /// Your request rate is too high. The AWS SDKs for DynamoDB automatically retry requests /// that receive this exception. Your request is eventually successful, unless your retry /// queue is too large to finish. Reduce the frequency of requests and use exponential /// backoff. For more information, go to Error /// Retries and Exponential Backoff in the Amazon DynamoDB Developer Guide. /// /// The operation tried to access a nonexistent table or index. The resource might not /// be specified correctly, or its status might not be ACTIVE. ///
public GetItem ( GetItemRequest request ) : GetItemResponse
request Amazon.DynamoDBv2.Model.GetItemRequest Container for the necessary parameters to execute the GetItem service method.
Résultat Amazon.DynamoDBv2.Model.GetItemResponse
        public GetItemResponse GetItem(GetItemRequest request)
        {
            var marshaller = new GetItemRequestMarshaller();
            var unmarshaller = GetItemResponseUnmarshaller.Instance;

            return Invoke<GetItemRequest,GetItemResponse>(request, marshaller, unmarshaller);
        }

Same methods

AmazonDynamoDBClient::GetItem ( string tableName, AttributeValue>.Dictionary key ) : GetItemResponse
AmazonDynamoDBClient::GetItem ( string tableName, AttributeValue>.Dictionary key, bool consistentRead ) : GetItemResponse

Usage Example

Exemple #1
0
        public bool CheckUserIsExist(string userID)
        {
            var config = new AmazonDynamoDBConfig();
            GetItemResponse response;
            config.ServiceURL = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"];
            client = new AmazonDynamoDBClient(config);
            bool retval = false;
            try
            {
                GetItemRequest request = new GetItemRequest
                {
                    TableName = "User",
                    Key = new Dictionary<string, AttributeValue>() { { "UserID", new AttributeValue { S = userID } } },
                    ReturnConsumedCapacity = "TOTAL"
                };
                response = client.GetItem(request);
                retval = response.Item.Count > 0;
            }
            catch (AmazonDynamoDBException e) { Console.WriteLine(e.Message); }
            catch (AmazonServiceException e) { Console.WriteLine(e.Message); }
            catch (Exception e) { Console.WriteLine(e.Message); }

            return retval;
        }
All Usage Examples Of Amazon.DynamoDBv2.AmazonDynamoDBClient::GetItem