Automapper - czy mapuje listy obiektów?
Mam następującą definicję Automapp:
Mapper.CreateMap<IB.BusinessComponents.Data.LocationMaster, IB.Entites.Master.Location>();
Mapper.CreateMap<IB.BusinessComponents.Data.LocationMaster, IB.Entites.Master.Location>()
.ForMember(destination => destination.Id, source => source.MapFrom(item => item.LocationMasterID))
.ForMember(destination => destination.ChildLocationList, source => source.Ignore());
To działa dobrze, gdy mapuję pojedynczy obiekt. Ale nie mogę przejść na listę przedmiotów. Czy podczas przechodzenia na listę potrzebuję innej definicji, czy nie jest to możliwe?
44
Author: Randy Minder, 2010-11-25
1 answers
W definicji Automapera:
CreateMap<MyStuffDTO, MyStuffViewModel>()
.ForMember(dto => dto.MyDate, opt => opt.MapFrom(src => src.LastDate))
.ForMember(dto => dto.MyTime, opt => opt.MapFrom(src => src.LastTime))
.ForMember(dto => dto.Category, opt => opt.MapFrom(src => src.Category));
W kodzie:
Dla Singla:
var result = Mapper.Map<MyStuffDTO, MyStuffViewModel>(obj);
Dla Listy:
var list = Mapper.Map<IList<MyStuffDTO>, IList<MyStuffViewModel>>(obj);
122
Author: ozczecho,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-11-26 13:17:21
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-11-26 13:17:21