FacilisDynamoDb.Extensions.DependencyInjection
0.0.7
dotnet add package FacilisDynamoDb.Extensions.DependencyInjection --version 0.0.7
NuGet\Install-Package FacilisDynamoDb.Extensions.DependencyInjection -Version 0.0.7
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FacilisDynamoDb.Extensions.DependencyInjection" Version="0.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FacilisDynamoDb.Extensions.DependencyInjection --version 0.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FacilisDynamoDb.Extensions.DependencyInjection, 0.0.7"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FacilisDynamoDb.Extensions.DependencyInjection as a Cake Addin #addin nuget:?package=FacilisDynamoDb.Extensions.DependencyInjection&version=0.0.7 // Install FacilisDynamoDb.Extensions.DependencyInjection as a Cake Tool #tool nuget:?package=FacilisDynamoDb.Extensions.DependencyInjection&version=0.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FacilisDynamoDb.Extensions.DependencyInjection
Overview
FacilisDynamoDb.Extensions.DependencyInjection is a simple AWS DynamoDB client that provides dependency injection extensions for .NET applications. It simplifies the integration of AWS DynamoDB with .NET applications by providing easy-to-use services and configurations.
Features
- Easy integration with AWS DynamoDB
- Dependency injection support
- Simple configuration
- Supports .NET Standard 2.0
Usage
Configuration
- Add the necessary services to the
WebApplicationBuilder
in yourProgram.cs
:
using FacilisDynamoDb.Extensions.DependencyInjection.Extensions;
WebApplicationBuilder builder = WebApplication.CreateSlimBuilder(args);
builder.Services.AddFacilisDynamoDbClient<TodoEntity>(AppJsonSerializerContext.Default);
builder.Services.AddTableOptions(builder.Configuration);
builder.Services.AddLocalAmazonDynamoDbClient(builder.Configuration.GetValue<string>("AmazonDynamoDbServiceUrl")!);
builder.Services.AddScoped<TableGenerator>();
builder.Services.ConfigureHttpJsonOptions(options =>
{
options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
});
WebApplication app = builder.Build();
- Define your DynamoDB entity:
public class TodoEntity : IIdentity
{
[JsonPropertyName(TableConstants.PrimaryKeyName)]
public string PrimaryKey { get; set; } = default!;
[JsonPropertyName(TableConstants.SortKeyName)]
public string SortKey { get; set; } = default!;
public int Id { get; set; }
public string? Title { get; set; }
public DateOnly? DueBy { get; set; }
public bool IsComplete { get; set; }
}
- Create and populate the DynamoDB table:
async Task CreateAmazonDynamoDbTableAsync(WebApplication app)
{
using IServiceScope scope = app.Services.CreateScope();
using TableGenerator tableGenerator = scope.ServiceProvider.GetRequiredService<TableGenerator>();
await tableGenerator.CreateTableAsync();
}
async Task PopulateDatabaseAsync(WebApplication app)
{
var sampleTodos = new TodoEntity[]
{
new() { Id = 1, PrimaryKey = "Note", SortKey = "1", Title = "Walk the dog", IsComplete = true },
new() { Id = 2, PrimaryKey = "Note", SortKey = "2", Title = "Do the dishes", DueBy = DateOnly.FromDateTime(DateTime.Now), IsComplete = true },
new() { Id = 3, PrimaryKey = "Note", SortKey = "3", Title = "Do the laundry", DueBy = DateOnly.FromDateTime(DateTime.Now.AddDays(1)), IsComplete = false }
};
using IServiceScope scope = app.Services.CreateScope();
using IFacilisDynamoDbClient<TodoEntity> client = scope.ServiceProvider.GetRequiredService<IFacilisDynamoDbClient<TodoEntity>>();
List<TodoEntity> notes = (await client.GetAllAsync("Note")).ToList();
if (notes.Count != 0) return;
foreach (TodoEntity sampleTodo in sampleTodos)
{
await client.CreateAsync(sampleTodo);
}
}
License
This project is licensed under the MIT License. See the LICENSE
file for more details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- FacilisDynamoDb (>= 0.0.7)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on FacilisDynamoDb.Extensions.DependencyInjection:
Package | Downloads |
---|---|
FacilisDynamoDb.Tests.Utils
Simple AWS DynamoDb client |
GitHub repositories
This package is not used by any popular GitHub repositories.