Problems with AutoMapper and List

1

Personal I have the following code:

            List<NFE_CABECALHOEntity> lista = new List<NFE_CABECALHOEntity>();

                Mapper.Initialize(cfg => { cfg.CreateMap<NFE_CABECALHO, NFE_CABECALHOEntity>(); });

            lista = Mapper.Map<List<NFE_CABECALHO> ,List<NFE_CABECALHOEntity>>(listaData);

But I can not get the objects from the Date list, am I doing something wrong?

You're experiencing the following error:

Mapping types: List 1 -> List 1 System.Collections.Generic.List 1[[Data.Entity.NFE_CABECALHO, Data, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null]] -> System.Collections.Generic.List 1 [[Entity.Model.NFE_CABECALHOEntity, Entity, Version = 1.8.2.0, Culture = neutral, PublicKeyToken = null]]

    
asked by anonymous 14.05.2018 / 21:07

1 answer

1

Try this:

Mapper.Initialize(cfg => { cfg.CreateMap<NFE_CABECALHO, NFE_CABECALHOEntity>(); });

var lista = Mapper.Map<List<NFE_CABECALHOEntity>>(listaData);

Mapper might be missing out because you're using two type arguments with a single parameter, so maybe you're calling the wrong method.

    
14.05.2018 / 21:31