Automapper -cannot resolve the Generic List

Posted by chugh97 on Stack Overflow See other posts from Stack Overflow or by chugh97
Published on 2010-03-24T12:11:30Z Indexed on 2010/03/24 12:13 UTC
Read the original article Hit count: 939

Filed under:
Mapper.CreateMap<BusinessObject, Proxy.DataContacts.DCObject>()
            .ForMember(x => x.ExtensionData, y => y.Ignore())
            .ForMember(z => z.ValidPlaces, a=> a.ResolveUsing(typeof(ValidPlaces)));
        Mapper.AssertConfigurationIsValid();  

   public class BusinessObject
    {
        public Enum1 Enum1 { get; set; }
        public List<ValidPlaces> ValidPlaces{ get; set; }
    }

public class ValidPlaces { public int No { get; set; }

    public string Name { get; set; }
}

   public class DCObject
    {
       [DataMember]
        public Enum1 Enum1 { get; set; }
[DataMember]
        public List<ValidPlaces> ValidPlaces{ get; set; }
    }

Mapper.CreateMap works find when Mapper.AssertConfigurationIsValid(); is called but when I actually call into the service the Automapper throws and excetion saying ValidPlaces could not be mapped.Works fine if I put Ignore() but ideally want that passed.Any AutoMapper experts out there pls help.

© Stack Overflow or respective owner

Related posts about automapper