Using .net core c# dynamo db
I was using the following method to save to my dynamo db:
public Task SaveAsync(T item)
{
return base.SaveAsync(item, _config);
}
And then in my controller I call the above as:
foreach (var data in myData)
{
//update data
await _dynamoDbManager.SaveAsync(data);
}
The above works fine but instead of saving individually I want to save at one using batch.
I dont know how I can write a similar Batch method. I tried with below:
public Task CreateBatch()
{
//The below is not correct as I dont know what to pass as <T> in below call.
return CreateBatchWrite<T>(_config);
}
I want to create the above method so that I can use it as below in my controller:
var batchWriter = CreateBatch();
foreach (var data in myData)
{
//update data
}
batchWriter.AddPutItems(myData);
await batchWriter.ExecuteAsync();
Can anyone help in writing my CreateBatchWrite method.