Hi Tim,
Thanks a lot for providing the support to nested facets feature. There is another challenge we are facing when trying to configure custom mapping.
Basically static abstract void Map(TSource source, TTarget target); does not seem to support immutable properties using init.
For example, the below
public record Person
{
public required string FirstName { get; init; }
public required string LastName { get; init; }
}
[Facet(typeof(Person), Configuration = typeof(PersonMapper))]
public partial record PersonDto
{
public string FullName { get; init; } = string.Empty;
}
public class PersonMapper : IFacetMapConfiguration<Person, PersonDto>
{
public static void Map(Person source, PersonDto target)
{
target = target with
{
FullName = $"{source.FirstName} {source.LastName}"
};
}
}
Would you consider to extend the interface to support the Map method with return value? It could be something like this:
public class PersonMapper : IFacetMapConfiguration<Person, PersonDto>
{
public static void Map(Person source, PersonDto target)
{
}
public static PersonDto MapTo(Person source, PersonDto target)
{
return target with
{
FullName = $"{source.FirstName} {source.LastName}"
};
}
}
Hi Tim,
Thanks a lot for providing the support to nested facets feature. There is another challenge we are facing when trying to configure custom mapping.
Basically
static abstract void Map(TSource source, TTarget target);does not seem to support immutable properties using init.For example, the below
Would you consider to extend the interface to support the Map method with return value? It could be something like this: