private static void SetPropertyValue(DynamoObject target, Property prop, JToken token) { if (prop.DataType.CLRType == typeof(string)) { prop.SetValue <string>(target, token.Value <string>()); } else if (prop.DataType.CLRType == typeof(Int32)) { prop.SetValue <Int32>(target, token.Value <Int32>()); } else if (prop.DataType.CLRType == typeof(Int64)) { prop.SetValue <Int64>(target, token.Value <Int64>()); } else if (prop.DataType.CLRType == typeof(Int16)) { prop.SetValue <Int16>(target, token.Value <Int16>()); } else if (prop.DataType.CLRType == typeof(double)) { prop.SetValue <double>(target, token.Value <double>()); } else if (prop.DataType.CLRType == typeof(float)) { prop.SetValue <float>(target, token.Value <float>()); } else if (prop.DataType.CLRType == typeof(decimal)) { prop.SetValue <decimal>(target, token.Value <decimal>()); } else if (prop.DataType.CLRType == typeof(DateTime)) { prop.SetValue <DateTime>(target, token.Value <DateTime>()); } else { var objValue = token.ToObject(prop.DataType.CLRType); if (objValue != null) { prop.SetValue <object>(target, objValue); } } }
/// <summary> /// Amazon DynamoDB Query Test /// </summary> /// <param name="input"></param> /// <param name="context"></param> /// <returns></returns> public async Task <DynamoObject <Document> > AmazonDynamoDbQuery(string tableName, string context) { DynamoObject <Document> dynamoQueryResponse = new DynamoObject <Document>(); try { using (var client = new AmazonDynamoDBClient(new BjjBuddyCredentials())) { var test = client.Config; Table bjjBuddy = Table.LoadTable(client, "BjjBuddy"); dynamoQueryResponse.Data = await bjjBuddy.GetItemAsync("Test"); } } catch (Exception exception) { } return(dynamoQueryResponse); }