1

I am using automapper to map two models. In my case I am importing XML file and binding it to model using automapper. I want to show error message to the user which will have all invalid columns/mappings so that user can change it in XML file and upload again.

try
  {
      GradeImportDto gradeImportDto = JsonConvert.DeserializeObject<GradeImportDto>(exportXMLjson);
      RequestImportGradeDto requestGradeDto = Mapper.Map<RequestImportGradeDto>(gradeImportDto);
      Grade grade = Mapper.Map<Grade>(requestGradeDto);
   }                                                           
   catch (AutoMapperMappingException ex)
   {
      throw new ApplicationValidationException(AppConstants.INVALID_VALUES_EXEPTION, ex.InnerException);
   }

I am catching AutoMapperMappingException and can see destination member list there in inner exception also I can see unmapped members list(invalid mappings list) in messages part of inner exception but I am not sure how can I fetch that list.

Can any one help me in getting the list of unmapped members or invalid members.

Shardul
  • 309
  • 1
  • 3
  • 17
  • https://github.com/AutoMapper/AutoMapper/search?q=GetUnmappedPropertyNames&unscoped_q=GetUnmappedPropertyNames – Lucian Bargaoanu Apr 05 '19 at 14:24
  • @LucianBargaoanu Thanks for sharing the link. But I am not getting how to use it. Are those all classes in the link you share are part of source code? – Shardul Apr 05 '19 at 18:47

0 Answers0