Goa.Clients.Dynamo 0.0.2-preview.2.1

This is a prerelease version of Goa.Clients.Dynamo.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Goa.Clients.Dynamo --version 0.0.2-preview.2.1
                    
NuGet\Install-Package Goa.Clients.Dynamo -Version 0.0.2-preview.2.1
                    
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="Goa.Clients.Dynamo" Version="0.0.2-preview.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Goa.Clients.Dynamo" Version="0.0.2-preview.2.1" />
                    
Directory.Packages.props
<PackageReference Include="Goa.Clients.Dynamo" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Goa.Clients.Dynamo --version 0.0.2-preview.2.1
                    
#r "nuget: Goa.Clients.Dynamo, 0.0.2-preview.2.1"
                    
#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.
#:package Goa.Clients.Dynamo@0.0.2-preview.2.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Goa.Clients.Dynamo&version=0.0.2-preview.2.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Goa.Clients.Dynamo&version=0.0.2-preview.2.1&prerelease
                    
Install as a Cake Tool

Goa.Clients.Dynamo

A high-performance DynamoDB client optimized for AWS Lambda functions. This package provides a lightweight, AOT-ready DynamoDB client with strongly-typed operations and comprehensive error handling using the ErrorOr pattern.

Installation

dotnet add package Goa.Clients.Dynamo

Features

  • Native AOT support for faster Lambda cold starts
  • Strongly-typed request/response objects
  • Minimal dependencies and memory allocations
  • Built-in error handling with ErrorOr pattern
  • Support for all DynamoDB operations (Get, Put, Update, Delete, Query, Scan, Batch, Transactions)
  • DynamoDB model attributes for structured data access

Usage

Basic Setup

using Goa.Clients.Dynamo;
using Microsoft.Extensions.DependencyInjection;

// Register DynamoDB client
services.AddDynamoDB();

// Or with custom configuration
services.AddDynamoDB(config =>
{
    config.ServiceUrl = "http://localhost:8000"; // For local DynamoDB
    config.Region = "us-west-2";
    config.LogLevel = LogLevel.Debug;
});

Model Definition with Attributes

[DynamoModel(PK = "USER#<Id>", SK = "PROFILE")]
[GlobalSecondaryIndex(Name = "EmailIndex", PK = "EMAIL#<Email>", SK = "USER")]
public class User
{
    public string Id { get; set; }
    public string Name { get; set; }
    public string Email { get; set; }
}

Basic Operations

using ErrorOr;
using Goa.Clients.Dynamo;
using Goa.Clients.Dynamo.Models;
using Goa.Clients.Dynamo.Operations.GetItem;
using Goa.Clients.Dynamo.Operations.PutItem;

public class UserService
{
    private readonly IDynamoClient _client;
    
    public UserService(IDynamoClient client)
    {
        _client = client;
    }
    
    public async Task<ErrorOr<User>> GetUserAsync(string userId)
    {
        var result = await _client.GetItemAsync("Users", builder =>
        {
            builder
                .WithKey("PK", $"USER#{userId}")
                .WithKey("SK", "PROFILE");
        });
        
        if (result.IsError)
            return result.FirstError;
            
        // Convert DynamoRecord to User object
        if (result.Value.Item == null)
            return Error.NotFound("User.NotFound", "User not found");
            
        return ConvertToUser(result.Value.Item);
    }
    
    public async Task<ErrorOr<Success>> SaveUserAsync(User user)
    {
        var result = await _client.PutItemAsync("Users", builder =>
        {
            builder
                .WithAttribute("PK", $"USER#{user.Id}")
                .WithAttribute("SK", "PROFILE")
                .WithAttribute("Name", user.Name)
                .WithAttribute("Email", user.Email);
        });
            
        return result.IsError ? result.FirstError : Result.Success;
    }
}

Query Operations

using Goa.Clients.Dynamo.Operations.Query;
using Goa.Clients.Dynamo.Models;

public async Task<ErrorOr<List<User>>> GetUsersByEmailAsync(string email)
{
    var users = await _client.QueryAllAsync("Users", builder =>
    {
        builder
            .WithIndex("EmailIndex")
            .WithKey(Condition.Equals("GSI_1_PK", $"EMAIL#{email}"));
    }).ToListAsync();
    
    return users.Select(ConvertToUser).ToList();
}

Available Operations

  • GetItem: Retrieve a single item by primary key
  • PutItem: Create or replace an item
  • UpdateItem: Modify specific attributes of an item
  • DeleteItem: Remove an item from the table
  • Query: Find items using primary key and optional filters
  • Scan: Read all items in a table with optional filters
  • BatchGetItem: Retrieve multiple items in a single request
  • BatchWriteItem: Put or delete multiple items in a single request
  • TransactWriteItems: Execute multiple write operations atomically
  • TransactGetItems: Retrieve multiple items atomically

Error Handling

All operations return ErrorOr<T> results, providing comprehensive error handling:

var result = await _client.GetItemAsync(request);

if (result.IsError)
{
    // Handle errors
    foreach (var error in result.Errors)
    {
        Console.WriteLine($"Error: {error.Description}");
    }
    return;
}

// Use successful result
var item = result.Value.Item;

Documentation

For more information and examples, visit the main Goa documentation.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Goa.Clients.Dynamo:

Package Downloads
Goa.Functions.Dynamo

DynamoDB stream processing for high-performance AWS Lambda functions

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.3-preview.1 49 8/23/2025
0.0.2-preview.2.3 112 8/18/2025
0.0.2-preview.2.2 133 8/17/2025
0.0.2-preview.2.1 87 8/17/2025
0.0.2-preview.2 270 8/9/2025
0.0.0-alpha.0.32 85 12/7/2024
0.0.0-alpha.0.20 77 10/27/2024