RepoDB icon indicating copy to clipboard operation
RepoDB copied to clipboard

Enhancement: Add a PropertyHandlerOptions and ClassHandlerOptions class

Open mikependon opened this issue 3 years ago • 0 comments

Describe the enhancement

Currently, when you handle the result via PropertyHandler and ClassHandler, the values are returned as argument to the callback method. See below for the property handlers.

TResult Get(TInput input,
            ClassProperty property);

TInput Set(TResult input,
            ClassProperty property);

And below is for the class handlers.

TEntity Get(TEntity entity,
            DbDataReader reader);

TEntity Set(TEntity entity);

This is good, but it is also limiting the user on the given options.


With this User Story, we will enable an option class as the return values to the handler, in which we could in the future extend it to any values required when handling how the models/properties are being hydrated or forwarded to the database.

For property handlers, it is good to introduce the PropertyHandlerOptions class.

public class PropertyHandlerOptions
{
     public ClassProperty Property { get; }
     public DbCommand Command { get; }
     public DbParameter Parameter { get; }
     ...
}

```csharp
TResult Get(TInput input,
            PropertyHandlerOptions options);

TInput Set(TResult input,
            PropertyHandlerOptions options);

For class handlers, it is good to introduce the ClassHandlerOptions class.

public class PropertyHandlerOptions
{
     public DbDataReader DataReader { get; }
     ...
}

TEntity Get(TEntity entity,
            PropertyHandlerOptions options);

TEntity Set(TEntity entity,
            PropertyHandlerOptions options);

mikependon avatar Sep 17 '22 20:09 mikependon