Ahojte, prvy krat pouzivam Autmapper v nadeji, ze mi ulahci pracu, ale narazil som na zvlastnu chybu, ktorej sice rozumiem, ale neviem co s nou.
Mam class
public class LookupCategoryDAL
{
public int LookupCategoryId { get; set; }
public string LookupCategoryDescription { get; set; }
}
a
public class LookupCategoryBizModel
{
public int LookupCategoryId { get; set; }
public string LookupCategoryDescription { get; set; }
}
a pri pokuse namapovat jednu do druhej
public IEnumerable<LookupCategoryBizModel> GetLookupCategories()
{
return _lookupProvider.GetLookupCategories().Select(m => Mapper.Map<LookupCategoryDAL, LookupCategoryBizModel>(m));
}
dostanem error:
Missing type map configuration or unsupported mapping.
Mapping types:
LookupCategoryDAL -> LookupCategoryBizModel
ProtektorySalak.Data.DataObjects.Domains.LookupCategoryDAL -> ProtektorySalak.Interfaces.Business.Entities.LookupCategoryBizModel
Inicializaciu mam aktualne v konstruktore, pretoze som uplne nedomyslel ako to spravit inak, ale nemal by to byt problem:
public DALFacade()
{
Mapper.Initialize(cfg => cfg.CreateMap<LookupCategoryBizModel, LookupCategoryDAL>().ReverseMap());
Mapper.Initialize(cfg => cfg.CreateMap<ProductBizModel, ProductDAL>().ReverseMap());
Mapper.Initialize(cfg => cfg.CreateMap<LookupBizModel, LookupDAL>().ReverseMap());
_lookupProvider = new LookupProvider();
_productProvider = new ProductProvider();
}
Mate nejaky tip, co mu moze vadit ? Vdaka.