У меня есть два класса, которые выглядят следующим образом:
public class Rule
{
public int Id { get; set; }
public RuleGroup RuleGroup { get; set; }
}
public class RuleGroup
{
public int Id { get; set; }
public List<Rule> RuleList { get; set; }
}
RuleGroup имеет список правил. Мои настройки AutoMapper следующие:
Mapper.CreateMap<RuleRecord, FirstSolar.Mes.Core.Entities.Recipe.Rule>()
.ForMember(destination => destination.RuleGroup, source => source.Ignore())
.ForMember(destination => destination.Id, source => source.MapFrom(item => item.RuleId));
Mapper.CreateMap<IList<RuleRecord>, IList<FirstSolar.Mes.Core.Entities.Recipe.Rule>>();
Mapper.CreateMap<RuleGroupRecord, FirstSolar.Mes.Core.Entities.Recipe.RuleGroup>()
.ForMember(destination => destination.Id, source => source.MapFrom(item => item.RuleGroupId));
Mapper.CreateMap<IList<RuleGroupRecord>, IList<FirstSolar.Mes.Core.Entities.Recipe.RuleGroup>>();
Когда я пытаюсь сопоставить RuleGroupRecord (объект LinqToSQL) с RuleGroup (DTO), AutoMapper говорит, что мне нужно добавить сопоставление для RuleGroup.RuleList. Мне интересно, почему, потому что я определил, как отобразить один RuleRecord и список.
Если бы мне пришлось, как бы я это сделал?