Skip to content

Instantly share code, notes, and snippets.

@ochilab
Created July 11, 2021 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ochilab/a0726550a48a5be3997ee97398458989 to your computer and use it in GitHub Desktop.
Save ochilab/a0726550a48a5be3997ee97398458989 to your computer and use it in GitHub Desktop.
DocumentModelを利用してDynamoDBを操作する
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.DocumentModel;
AmazonDynamoDBClient client = null;
Table table = null;
client = new AmazonDynamoDBClient();
//目的のテーブルを取得
table = Table.LoadTable(client, tableName);
//Documentクラスを利用する
var item = new Document();
item["id"] = id;//キーに相当
//登録する場合
table.PutItemAsync(item);
//キーで検索する場合
var result= table.GetItemAsync(id).Result;
//キーで削除する場合
table.DeleteItemAsync(id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment