Mapster icon indicating copy to clipboard operation
Mapster copied to clipboard

Mapster tool How to declare custom mapping.

Open Alexandr-Pletnev opened this issue 1 year ago • 0 comments

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?

Alexandr-Pletnev avatar Mar 04 '24 09:03 Alexandr-Pletnev