Mapster icon indicating copy to clipboard operation
Mapster copied to clipboard

Please add support to map into specific dictionary keys

Open cytoph opened this issue 4 years ago • 1 comments

It would be great if something like this would be possible:

config.NewConfig<DataRow, FormatDescriptor>()
    .Map(f => f.DateFormat, dr => dr.Field<string>("DateFormat"))
    // [...]
    .Map(f => f.DecimalDigits[DecimalType.None], dr => dr.Field<bool>("DigitsNone"))
    .Map(f => f.DecimalDigits[DecimalType.Rate], dr => dr.Field<bool>("DigitsRate"))
    .Map(f => f.DecimalDigits[DecimalType.Sum], dr => dr.Field<bool>("DigitsSum"))
    // [...]
    ;

Currently my only workaround for this is the following (which is kind of ugly):

config.NewConfig<DataRow, FormatDescriptor>()
    .Map(f => f.DateFormat, dr => dr.Field<string>("DateFormat"))
    // [...]
    .AfterMapping((dr, f) =>
    {
        f.DecimalDigits[DecimalType.None] = dr.Field<bool>("DigitsNone");
        f.DecimalDigits[DecimalType.Rate] = dr.Field<bool>("DigitsRate");
        f.DecimalDigits[DecimalType.Sum] = dr.Field<bool>("DigitsSum");
        // [...]
    };

Is something like this already possible in any way? If no, it would really be nice, to have that functionality.

cytoph avatar Jun 09 '22 13:06 cytoph

In order to identify issues that are still active, we are closing issues that we believe are either resolved or are dormant. If your issue is still active then please reopen. Thanks.

stagep avatar Jan 07 '25 18:01 stagep