Im trying to use automapper to map from one record to a new record and add a few defaults based on some logic. I was originally expecting "ForCtorParam" to work, but im still getting the same exception after adding it.
public record Source(
int number);
public record Destination(
int number,
string numberAsString);
[Fact]
public void automapperTest()
{
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<Source, Destination>()
.ForCtorParam("numberAsString", (opt) => opt.MapFrom((src) => src.number.ToString()));
});
config.AssertConfigurationIsValid();
}
Im not sure if i am trying to do something that is not intended or missunderstanding the automapper documentation.
Hoping someone in here can help TIA