Skip to content

Add support for DynamoDBAutoGeneratedTimestampAttribute and DynamoDbUpdateBehaviorAttribute #3892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: development
Choose a base branch
from

Conversation

irina-herciu
Copy link
Contributor

@irina-herciu irina-herciu commented Jun 23, 2025

Add

  • support for the [DynamoDBAutoGeneratedTimestamp] attribute to the .NET SDK for DynamoDB, enabling automatic setting of timestamp fields during save operations. This feature aligns with the Java SDK's @DynamoDbAutoGeneratedTimestampAttribute.
  • support for [DynamoDbUpdateBehavior] attribute to the .NET SDK for DynamoDB, enabling update behavior for a property when performing DynamoDB update operations. This feature aligns with the Java SDK's @DynamoDbUpdateBehavior.

Description

  • New Attributes: [DynamoDBAutoGeneratedTimestamp] and [DynamoDbUpdateBehavior]

    • [DynamoDBAutoGeneratedTimestamp] Automatically sets the property to the current UTC timestamp (DateTime.UtcNow) on item save.
    • [DynamoDbUpdateBehavior] Specifies the update behavior for a property when performing DynamoDB update operations. This attribute can be used to control whether a property is always updated, only updated if not null.
  • Update Behavior Modes:

    • IfNotExists: Set the value only when the item is created.
    • Always: Set the value on both create and update.
  • Usage:

    class Order
    {
        [DynamoDBHashKey]
        public string Id { get; set; }
    
        [DynamoDBAutoGeneratedTimestamp]
        [DynamoDbUpdateBehavior(UpdateBehavior.IfNotExists)]
        public DateTime CreatedAt { get; set; }
    
        [DynamoDBAutoGeneratedTimestamp]
        [DynamoDBProperty(StoreAsEpoch = true)]
        public DateTime? UpdatedAt { get; set; }
    }

Motivation and Context

Testing

unit and integration tests added

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

@irina-herciu irina-herciu changed the title Add support for DynamoDBAutoGeneratedTimestampAttribute that sets current timestamp during persistence operations. Add support for DynamoDBAutoGeneratedTimestampAttribute and DynamoDbUpdateBehaviorAttribute Jul 7, 2025
@irina-herciu irina-herciu marked this pull request as ready for review July 7, 2025 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant