I'm having trouble displaying these two classes (Control -> ControlVM)
public class Control
{
public IEnumerable<FieldType> Fields { get; set; }
public class FieldType
{
}
}
public class ControlVM
{
public FieldList Fields { get; set; }
public class FieldList
{
public IEnumerable<FieldType> Items { get; set; }
}
public class FieldType
{
}
}
I tried with opt.ResolveUsing(src => new { Items = src.Fields }), but AutoMapper apparently cannot resolve the anonymous type. Also tried the extension ValueResolver, but also did not work.
NOTE. . This virtual machine is later used by WebApi, and JSON.NET needs a wrapper around the collection to deserialize it. Therefore, removing the shell is not a solution.
NOTE2: I also do Mapper.CreateMap<Control.FieldType, ControlVM.FieldType>(), so there is no problem there.
faloi source
share