I have an IList<AdminVAT>
and I'd like to copy this collection to IList<AdminVATDto>
collection
I tried this :
IList<AdminVAT> listAdminVAT = new AdministrationService(session).ListDecimal<AdminVAT>();
AutoMapper.Mapper.CreateMap<IList<AdminVAT>, List<AdminVATDTO>>();
var res = AutoMapper.Mapper.Map<IList<AdminVAT>, IList<AdminVATDTO>>(listAdminVAT);
I receive this exception :
Trying to map System.Collections.Generic.IList`1[[AdminVAT, eSIT.GC.DataModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] to System.Collections.Generic.IList`1[[AdminVATDTO, eSIT.GC.WebUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].
Thanks.
Update1
public class AdminVAT : IAdminDecimal
{
public virtual int Id { get; set; }
public virtual int Code { get; set; }
public virtual decimal Value { get; set; }
}
public class AdminVATDTO : AdminVAT
{
[DisplayFormat(DataFormatString = "{0:n2}", ApplyFormatInEditMode = true)]
public override decimal Value { get; set; }
}
I still have 5 decimal in my dropdown list ...
Controller :
IList<AdminVAT> listAdminVAT = new AdministrationService(session).ListDecimal<AdminVAT>();
AutoMapper.Mapper.CreateMap<AdminVAT, AdminVATDTO>();
model.ListVAT = AutoMapper.Mapper.Map<IList<AdminVAT>, IList<AdminVATDTO>>(listAdminVAT);
HTML :
@Html.DropDownList("ddVAT", new SelectList(Model.ListVAT, "Id", "Value", Model.Estimation.AdminVAT))