Created
May 9, 2021 19:46
-
-
Save rahulpnath/3a2b175a78f3007490b0541b307b0ac5 to your computer and use it in GitHub Desktop.
Connect to Local instance of 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 System; | |
using System.Threading.Tasks; | |
using Amazon.DynamoDBv2; | |
using Amazon.DynamoDBv2.DataModel; | |
using Amazon.Runtime; | |
using ConsoleTables.Core; | |
namespace dynamodb_local_sample | |
{ | |
class Program | |
{ | |
static async Task Main(string[] args) | |
{ | |
Console.WriteLine("Hello World!"); | |
var creds = new BasicAWSCredentials("fakeMyAccessKeyId", "fakeSecretAccessKe"); | |
var config = new AmazonDynamoDBConfig() | |
{ | |
ServiceURL = "http://localhost:8002", | |
AuthenticationRegion = "ap-southeast-2", | |
}; | |
var client = new AmazonDynamoDBClient(creds, config); | |
var context = new DynamoDBContext(client); | |
var newData = new WeatherForecast() {City = "Brisbane", Date = DateTime.Now.ToString()}; | |
// await context.SaveAsync(newData); | |
var data = await context.ScanAsync<WeatherForecast>(null).GetRemainingAsync(); | |
ConsoleTable.From(data).Write(); | |
Console.Read(); | |
} | |
} | |
public class WeatherForecast | |
{ | |
public string City { get; set; } | |
public string Date { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment