public DynamoDBItem MergeData(DynamoDBItem data) { var dataDict = data.ToDictionary(); var merged = _data.Union(dataDict).ToDictionary(k => k.Key, v => v.Value); return(new DynamoDBItem(merged)); }
private DynamoDBItem DynamoDBKey(string pk, string sk) { var dbItem = new DynamoDBItem(); dbItem.AddPK(pk); dbItem.AddSK(sk); return(dbItem); }
public async Task BatchDeleteItemsAsync(IEnumerable <TKey> items) { var dbItems = new List <DynamoDBItem>(); foreach (var item in items) { var dbItem = new DynamoDBItem(); dbItem.AddPK(PKValue(item)); dbItem.AddSK(SKValue(item)); dbItems.Add(dbItem); } await _dynamoDbClient.BatchDeleteItemsAsync(dbItems); }
public async Task BatchDeleteItemsAsync(TKey parentKey, IEnumerable <TKey> items) { var pk = PKValue(parentKey); var dbItems = new List <DynamoDBItem>(); foreach (var item in items) { var relationKey = GetRelationKey(parentKey, item); var dbItem = new DynamoDBItem(); dbItem.AddPK(pk); dbItem.AddSK(SKValue(relationKey)); dbItems.Add(dbItem); } await _dynamoDbClient.BatchDeleteItemsAsync(dbItems); }
public async Task PutItemAsync(string pk, string sk, DynamoDBItem item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } var dbItemKey = DynamoDBKey(pk, sk); var dbItemData = dbItemKey.MergeData(item); var putItemRq = new PutItemRequest { TableName = TableName, Item = dbItemData.ToDictionary() }; var result = await _dynamoDbClient.PutItemAsync(putItemRq); }
protected abstract TEntity FromDynamoDb(DynamoDBItem item);