Last active
August 18, 2019 14:24
-
-
Save gistlyn/d607e070cca190e0d59368dd6b9b147c 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; | |
namespace MyApp | |
{ | |
public class ConfigureDynamoDb : IConfigureServices | |
{ | |
IConfiguration Configuration { get; } | |
public ConfigureDynamoDb(IConfiguration configuration) => Configuration = configuration; | |
public void Configure(IServiceCollection services) | |
{ | |
var awsDb = new AmazonDynamoDBClient("keyId","key", new AmazonDynamoDBConfig { | |
ServiceURL = 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