Skip to content
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

Support DynamoDBHashKey and DynamoDBRangeKey attributes #27

Open
howcheng opened this issue Jan 8, 2016 · 1 comment
Open

Support DynamoDBHashKey and DynamoDBRangeKey attributes #27

howcheng opened this issue Jan 8, 2016 · 1 comment

Comments

@howcheng
Copy link

howcheng commented Jan 8, 2016

If an entity has property names that are different from the key column names, you are supposed to use the [Amazon.DynamoDBv2.DataModel.DynamoDBHashKey] attribute, but it looks like you don't support this yet in the EntityKeyGetter class. You can probably make a method to scan the entity's properties for these attributes.

@LCHarold
Copy link
Contributor

Here's a method I'm using in a generic base class to get the hash key property name:

public static string GetHashKey<T>()
{
    return (typeof(T).GetProperties()
        .Where(p => p.GetCustomAttributes<DynamoDBHashKeyAttribute>()
        .Any())
        .Select(p => p.Name))
        .First();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants