Model view controller 使用自动映射器

Model view controller 使用自动映射器,model-view-controller,mapping,automapper,Model View Controller,Mapping,Automapper,我有一个客户端类需要映射到clientViewModel的一个不太复杂的类,下面是两个类: public class client { public int clientRef{get;set;} public string Title{get;set;} public string Forename { get; set; } public string Initials { get; set; } public string Surname { get; set; } Public Addr

我有一个客户端类需要映射到clientViewModel的一个不太复杂的类,下面是两个类:

public class client
{
public int clientRef{get;set;}
public string Title{get;set;}
public string Forename { get; set; }
public string Initials { get; set; }
public string Surname { get; set; }
Public Address address{get;set;}
 }

这就是我映射模型的方式(它只是一个概念证明)

IList\u clientsViewModelsclients=new List();
var模型=
新客户端().Get(10);
CreateMap();
ClientsViewModel cv=Mapper.Map(model);
_clientsViewModelsclients.Add(cv);
返回视图(_clientsViewModelsclients);
问题是在视图上,我可以看到名称和标题,但看不到地址。如果我不确定address类的address line 1 odf中的任何内容都映射到clientViewModel类的Line1,那么我还应该进行其他映射吗

谢谢你的评论

请看这里:或者您可以创建一个自定义解析器


请看这里:或者您可以创建一个自定义解析器。。非常感谢@TryingToImprove
public class ClientsViewModel
{
    public int ClientRef { get; set; }
    public string Title { get; set; }
    public string Forename { get; set; }
    public string Initials { get; set; }
    public string Surname { get; set; }
    public string Line1 { get; set; }
    public string Line2 { get; set; }
    public string Line3 { get; set; }
    public string Town { get; set; }
    public string County { get; set; }
    public string Postcode { get; set; }
    public string Country { get; set; }       
}
        IList<ClientsViewModel> _clientsViewModelsclients = new List<ClientsViewModel>(); 

        var model =
            new Clients().Get(10);
        Mapper.CreateMap<Client, ClientsViewModel>();

       ClientsViewModel cv = Mapper.Map<Client, ClientsViewModel>(model);

       _clientsViewModelsclients.Add(cv);

       return View(_clientsViewModelsclients);