EfficientDynamoDb icon indicating copy to clipboard operation
EfficientDynamoDb copied to clipboard

Batch.PutItem and friends to accept, Type and object. Also for single entity operations

Open wjax opened this issue 2 years ago • 3 comments

In order to make some complex repositories, It would be great to be able to call Put, Delete and other methods with Type and object.

Under the hood, the library is making typeof(TEntity) and casting intance to object

Example

public static IBatchPutItemBuilder PutItem<TEntity>(TEntity entity) where TEntity : class => (IBatchPutItemBuilder) new BatchPutItemBuilder(typeof (TEntity), (object) entity);

If we add a new method signature like PutItem(object o, Type t) we could play better with reflection scenarios.

What do you think?

wjax avatar May 30 '22 11:05 wjax

Hey @wjax,

We didn't plan to expose this API because it might be confusing and not really popular. Could you explain more about your use case? We could try find a solution without exposing such APIs

firenero avatar Jun 06 '22 13:06 firenero

The intention is to add Single table design extensions.

So I came up with some annotations and "magic" that allows to create single table design with some out of the box relationsships management in a very transparent manner.

For that to work, I need to use reflection (with as many caching as possible) and so I need to call efficient dynamo lib with runtime types

wjax avatar Jun 28 '22 11:06 wjax

Sorry for the long delay.

You can use reflection to call the generic methods with runtime types. Quick search shows this SO question with examples: https://stackoverflow.com/questions/232535/how-do-i-use-reflection-to-call-a-generic-method

firenero avatar Jul 09 '22 14:07 firenero

Closing this one because there is no changes required to the library. Feel free to reopen this issue if you have additional info to the original issue.

firenero avatar Sep 27 '22 08:09 firenero