Automapper failing to map on IEnumerable

后端 未结 2 1447
情歌与酒
情歌与酒 2021-02-02 05:31

I have two classes like so:

public class SentEmailAttachment : ISentEmailAttachment
{
    public SentEmailAttachment();

    public string FileName { get; set; }         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-02 06:29

    You do not need to explicitly map collection types, only the item types. Just do:

    Mapper.CreateMap();
    var attachments = Mapper.Map, List>(someList);
    

    That will work just fine.

提交回复
热议问题