Mapping dictionaries with AutoMapper

后端 未结 2 1894
名媛妹妹
名媛妹妹 2020-12-03 14:03

Given this these classes, how can I map a dictionary of them?

public class TestClass
{
    public string Name { get; s         


        
2条回答
  •  再見小時候
    2020-12-03 14:29

    AutoMapper has changed a bit so it looks more like:

    CreateMap()
         .ReverseMap();
    CreateMap>()
         .ConstructUsing((t, ctx) => new KeyValuePair(t.id, ctx.Mapper.Map(t)));
    

提交回复
热议问题