Skip to content

Instantly share code, notes, and snippets.

@ochilab
Created June 20, 2013 11:21
Show Gist options
  • Save ochilab/5821961 to your computer and use it in GitHub Desktop.
Save ochilab/5821961 to your computer and use it in GitHub Desktop.
C#でDynamoDBにMapperを利用してデータを保存するサンプル
using Amazon.DynamoDB;
using Amazon.DynamoDB.Model;
using Amazon.DynamoDB.DataModel;
public static void Main(string[] args) {
Console.WriteLine("Setting up DynamoDB client");
client = new AmazonDynamoDBClient(RegionEndpoint.USEast1);
DynamoDBContext context = new DynamoDBContext(client);
SampleData sample = new SampleData();
sample.id = "0000";
sample.name = "ochilab";
sample.value = "日本語";
context.Save(sample);
}
using Amazon.DynamoDB.DataModel;
[DynamoDBTable("DynaTest")]
class SampleData {
[DynamoDBHashKey(AttributeName = "id")]
public string id { get; set; }
[DynamoDBRangeKey(AttributeName = "name")]
public String name { get; set; }
[DynamoDBProperty("value")]
public String value { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment