EfficientDynamoDb icon indicating copy to clipboard operation
EfficientDynamoDb copied to clipboard

Allow custom converters to access ToDocument and ToEntity (like existing internal methods)

Open bbdaniell opened this issue 4 months ago • 1 comments

The problem we're trying to solve is having a converter that allows us to serialize & deserialize derived classes. We currently have a working solution based on this approach, but we've run into some limitations.

We don't want to have to write a custom converter for each subtype, because the types are relatively so like in the linked example we rely on an injected DynamoDbContext.ToEntity<T> to convert each subtype. But we'd like to be able to register the converter for the type on the class property or context like the documentation.

It seems like it should be possible by registering a DdbConverterFactory, but there's no obvious way to go from DynamoDbContextMetadata to a DynamoDbContext. These extension methods also look like they would work, which I think is how the internal ObjectDdbConverter class works, but I don't know what the implications of using those elsewhere would be.

If there's a better way to do what we're trying to do I'd be glad to hear it!

bbdaniell avatar Oct 21 '24 07:10 bbdaniell