コード例 #1
0
        public virtual void CreateAccountItem(AmazonDynamoDBClient ddbClient, string tableName, Account account)
        {
            // Create the request
            var putItemRequest = new PutItemRequest
            {
                TableName = tableName,
                Item = new Dictionary<string, AttributeValue>
                {
                    {"Company", new AttributeValue {S = account.Company}},
                    {"Email", new AttributeValue {S = account.Email}}
                }
            };

            // Only add attributes if the coresponding property in the account object is not empty.
            if (!String.IsNullOrEmpty(account.First))
            {
                putItemRequest.Item.Add("First", new AttributeValue {S = account.First});
            }
            if (!String.IsNullOrEmpty(account.Last))
            {
                putItemRequest.Item.Add("Last", new AttributeValue {S = account.Last});
            }
            if (!String.IsNullOrEmpty(account.Age))
            {
                putItemRequest.Item.Add("Age", new AttributeValue {N = account.Age});
            }

            // Submit the request
            ddbClient.PutItem(putItemRequest);
        }
コード例 #2
0
 /// <summary>
 ///     Create a DynamoDB item from the values specified in the account parameter. The names of the attributes in
 ///     the item should match the corresponding property names in the Account object. Don't add attributes for fields
 ///     in the Account object that are empty (hint: use String.IsNullOrEmpty() method on the value).
 ///     Since the Company and Email attributes are part of the table key, those will always be provided in
 ///     the Account object when this method is called.
 ///     Important: Even though the Account.Age property is passed to you as a string, store it in the  DynamoDB item
 ///     as a numerical value.
 /// </summary>
 /// <param name="ddbClient">The DynamoDB client object.</param>
 /// <param name="tableName">The name of the table to add the items to.</param>
 /// <param name="account">The Account object containing the data to add.</param>
 /// <remarks>The purpose of this task is to give you experience constructing request objects for interacting with DynamoDB.</remarks>
 public override void CreateAccountItem(AmazonDynamoDBClient ddbClient, string tableName, Account account)
 {
     //TODO: Replace this call to the base class with your own method implementation.
     base.CreateAccountItem(ddbClient, tableName, account);
 }