An exception of type 'AutoMapper.AutoMapperMappingException' occurred in AutoMapper.dll but was not handled in user code

后端 未结 1 902
天命终不由人
天命终不由人 2021-01-11 16:59

Somehow my code doesn\'t work any more (it did work before with the exact same code). This is the problem:

The code

I\'m trying to map some

1条回答
  •  终归单人心
    2021-01-11 17:17

    It seems like there is a problem with mapping Authors property. This Aggregate call will throw an exception if the Authors sequence is null or empty.

    .ForMember(x => x.Authors, 
               opt => opt.MapFrom(src => src.Book.Authors.Select(x => x.Name).Aggregate((i, j) => i + ", " + j)))
    

    0 讨论(0)
提交回复
热议问题