MapsterMapper / Mapster

A fast, fun and stimulating object to object Mapper
MIT License
4.29k stars 327 forks source link

map string to guid #578

Closed jtsai-dev closed 1 year ago

jtsai-dev commented 1 year ago

i am trying to map string to Guid, and i also hope it could be deal with empty string, so i set the config like this

TypeAdapterConfig<string, Guid>.NewConfig()
                .Map(dest => dest, src => src == "" ? Guid.Empty : Guid.Parse(src));

but it still throw an exception System.FormatException:“Unrecognized Guid format.” when Adapt empty string var gid = "".Adapt<Guid>(); , is there a configuration i am missing?

jtsai-dev commented 1 year ago

just ignore this question, i had saw the MapWith for this case