agileobjects/AgileMapper

Unable to map class if property has JsonDocument class

NanFengCheong opened this issue · 3 comments

Hi,

Might this be the same situation as issue #191 ?

Steve

Actually, sorry - I think it's just a configuration issue.

Instead of:

Mapper.WhenMapping
    .From<JsonDocument>()
    .ToANew<JsonDocument>()
    .CreateInstancesUsing(ctx => JsonDocument.Parse(ctx.Source.RootElement.GetRawText(), default));

Use:

Mapper.WhenMapping
    .From<JsonDocument>()
    .To<JsonDocument>()
    .CreateInstancesUsing(ctx => JsonDocument.Parse(ctx.Source.RootElement.GetRawText(), default));

Using ToANew<T>() applies the configuration only to new object mappings, not to updates as you're doing in your fiddle.

Hope that helps,

Steve

Seems working now. Thanks