Created
November 11, 2021 14:56
-
-
Save gistlyn/32810f81c3164c1dbd31d4100972054a to your computer and use it in GitHub Desktop.
Use AWS DynamoDB and PocoDynamo
This file contains hidden or 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
dotnet add package ServiceStack.Aws |
This file contains hidden or 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 Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.DependencyInjection; | |
using ServiceStack; | |
using ServiceStack.Aws; | |
using ServiceStack.Aws.DynamoDb; | |
using Amazon; | |
using Amazon.DynamoDBv2; | |
[assembly: HostingStartup(typeof(MyApp.ConfigureDynamoDb))] | |
namespace MyApp | |
{ | |
public class ConfigureDynamoDb : IHostingStartup | |
{ | |
public void Configure(IWebHostBuilder builder) => builder | |
.ConfigureServices((context, services) => { | |
var awsDb = new AmazonDynamoDBClient("keyId","key", new AmazonDynamoDBConfig { | |
ServiceURL = context.Configuration.GetConnectionString("DynamoDb") ?? "http://localhost:8000" | |
}); | |
var db = new PocoDynamo(awsDb); | |
services.AddSingleton<IAmazonDynamoDB>(awsDb); | |
services.AddSingleton<IPocoDynamo>(db); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment