I am currently facing an error whilst trying to map data objects as shown below;
Method 'get_Item' in type 'Proxy_System.Collections.Generic.IList`1[[InsureAfrika_API.Model.DataModel, InsureAfrika API, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]_28141317_' from assembly 'AutoMapper.Proxies, Version=0.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005' does not have an implementation.
Below are my data sources; QuoteSourceDto
public string ResponseStatus { get; set; }
public IList<Data> Data { get; set; }
DataClass
public string Client { get; set; }
public IList<Extensions> Extensions { get; set; }
Extensions Source Class
public Decimal Limit { get; set; }
public Decimal Rate { get; set; }
My Destination Class; QuoteDestinationModel
public string ResponseStatus { get; set; }
public IList<DataModel> Data { get; set; }
DataModel
public string Client { get; set; }
public IList<ExtensionsModel> Extensions { get; set; }
ExtensionModel Class
public Decimal Limit { get; set; }
public Decimal Rate { get; set; }
Below is my mapper configuration;
var config = new MapperConfiguration(cfg => {
cfg.CreateMap<IList<Extensions>, IList<ExtensionsModel>>();
cfg.CreateMap<IList<Data>, IList<DataModel>>();
cfg.CreateMap<QuoteSourceDto, QuoteDestinationModel>()
.ForMember(dest => dest.Data, opt => opt.MapFrom(src => src.Data))
.ForMember(dest => dest.ResponseStatus, opt => opt.Ignore());
})
My Data Source;
IList<Extensions> exts =new List<Extensions>
{
new Extensions{Rate=1.34M,Limit=21400.00M};
}
IList<Data> dat = new List<Data>
{
new Data{Client="Micael Angelus", Extensions =exts};
};
QuoteSourceDto dtos = new QuoteSourceDto
{
ResponseStatus = "Success",
Data = dat
};
Thus my Map function call is as shown below;
var _client = mapper.Map<QuoteSourceDto, QuoteDestinationModel>(dtos);
When I use type List it returns no error and no result just an empty list and when I use IList it returns the stated error above. All I want to do is map results to QuoteDestinationModel.
EDIT I'm Using Automapper Version 9.0.0