How do I get AutoMapper to not cache mapped objects?

前端 未结 5 1755
不思量自难忘°
不思量自难忘° 2021-02-04 00:37

When AutoMapper encounters an object that\'s already been mapped, it seems to use that object again, instead of trying to re-map it. I believe it does this based on .Equal

5条回答
  •  被撕碎了的回忆
    2021-02-04 00:59

    There is now an option to disable the cache.

    Mapper.CreateMap();
    var results = Mapper.Map, IList>(source, opt => opt.DisableCache = true);
    

提交回复
热议问题