AWS SDK Version 4 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Marks a property or field as an atomic counter in DynamoDB. This attribute indicates that the associated property or field should be treated as an atomic counter, which can be incremented or decremented directly in DynamoDB during update operations. It is useful for scenarios where you need to maintain a counter that is updated concurrently by multiple clients without conflicts. The attribute also allows specifying an alternate attribute name in DynamoDB using the `AttributeName` property, as well as configuring the increment or decrement value (`Delta`) and the starting value (`StartValue`).

Inheritance Hierarchy

System.Object
  System.Attribute
    Amazon.DynamoDBv2.DataModel.DynamoDBAttribute
      Amazon.DynamoDBv2.DataModel.DynamoDBRenamableAttribute
        Amazon.DynamoDBv2.DataModel.DynamoDBAtomicCounterAttribute

Namespace: Amazon.DynamoDBv2.DataModel
Assembly: AWSSDK.DynamoDBv2.dll
Version: 3.x.y.z

Syntax

C#
public sealed class DynamoDBAtomicCounterAttribute : DynamoDBRenamableAttribute

The DynamoDBAtomicCounterAttribute type exposes the following members

Constructors

NameDescription
Public Method DynamoDBAtomicCounterAttribute()

Default constructor

Public Method DynamoDBAtomicCounterAttribute(string, Int64, Int64)

Constructor that specifies an alternate attribute name

Public Method DynamoDBAtomicCounterAttribute(Int64, Int64)

Constructor that specifies an alternate attribute name

Properties

NameTypeDescription
Public Property AttributeName System.String Inherited from Amazon.DynamoDBv2.DataModel.DynamoDBRenamableAttribute.
Public Property Delta System.Int64

The value to increment (positive) or decrement (negative) the counter with for each update.

Public Property StartValue System.Int64

The starting value of the counter.

Public Property TypeId System.Object Inherited from System.Attribute.

Examples

Example usage:
public class Example
{
    [DynamoDBAtomicCounter]
    public long Counter { get; set; }
            
    [DynamoDBAtomicCounter("CustomCounterName", delta: 5, startValue: 100)]
    public long CustomCounter { get; set; }
}
            
In this example: - `Counter` will be treated as an atomic counter with the same name in DynamoDB. - `CustomCounter` will be treated as an atomic counter with the attribute name "CustomCounterName" in DynamoDB, incremented by 5 for each update, and starting with an initial value of 100.

Version Information

.NET:
Supported in: 8.0 and newer, Core 3.1

.NET Standard:
Supported in: 2.0

.NET Framework:
Supported in: 4.7.2 and newer