Created
July 11, 2021 03:57
-
-
Save ochilab/a0726550a48a5be3997ee97398458989 to your computer and use it in GitHub Desktop.
DocumentModelを利用してDynamoDBを操作する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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