Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
For use with Amazon DynamoDB DataModel API for .NET. This class can be used to automagically serialize enum properties to DynamoDB, by decorating the property with the attribute [DynamoDBProperty(typeof(DynamoEnumConverter<AccountStatus>))], where "AccountStatus" is the name of the enumerated type..
public class DynamoEnumConverter<TEnum> : IPropertyConverter
public object FromEntry(DynamoDBEntry entry)
string valueAsString = entry.AsString();
TEnum valueAsEnum = (TEnum)Enum.Parse(typeof(TEnum), valueAsString);
return valueAsEnum;
public DynamoDBEntry ToEntry(object value)
string valueAsString = value.ToString();
DynamoDBEntry entry = new Primitive(valueAsString);
return entry;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment