EDIT: The title is incorrect, I'm trying to map from the source list to the list of source source models.
I am having trouble trying to match the list to another one specified in the nested model. View and inconsistency. The problem is that I do not know how to make comparisons.
Here is my setup after unsuccessful matching attempts:
public class DestinationModel
{
public DestinationNestedViewModel sestinationNestedViewModel { get; set; }
}
public class DestinationNestedViewModel
{
public List<ItemModel> NestedList { get; set; }
}
public class SourceModel
{
public List<Item> SourceList { get; set; }
}
Where Item and ItemModel already have a mapping defined between them
I canβt do that ...
Mapper.CreateMap<SourceModel, DestinationModel>()
.ForMember(d => d.DestinationNestedViewModel.NestedList,
opt => opt.MapFrom(src => src.SourceList))
ERROR:
The expression 'd => d.DestinationNestedViewModel.NestedList' must be allowed for the top-level element. Parameter Name: lambdaExpression
Then I tried something like this:
.ForMember(d => d.DestinationNestedViewModel,
o => o.MapFrom(t => new DestinationNestedViewModel { NestedList = t.SourceList }))
NestedList = t.SourceList.
, ItemModel Item . .
?