Mapster
Mapster copied to clipboard
Mapster tool How to declare custom mapping.
Hello all.
We want to use mapster tool to auto-generate DTOs and Mappers. But we don't understand how we can declare custom mapping.
For example:
var builder = config.AdaptTo("[name]Dto", MapType.Map)
.ForType<ProjectDocument>(cfg =>
{
cfg.Map(src => src.ProjectXml, typeof(string), "ProjectXmlAsJson", srcValue => "some logic to return dest value");
});
We want to implement "some logic to return dest value". We need to serialize src value to string.
How can we do it?