我在使用此模型的 Automapper 时遇到问题
public class Contact
{
public string Name { get; set; }
public string Email { get; set; }
public string MessageTitle { get; set; }
public string MessageBody { get; set; }
public string MessageTime { get; set; }
}
和这个 ViewModel
public class ContactView
{
public string Name { get; set; }
public string Email { get; set; }
public string MessageTitle { get; set; }
public string MessageBody { get; set; }
public string MessageTime { get; set; }
}
这是我的转换方法:
//Convert to Model
public static Contact ConvertToContactModel(this ContactView contactView)
{
return Mapper.Map<ContactView, Contact>(contactView);
}
//Convert to ViewModel
public static ContactView ConvertToContactView(this Contact contact)
{
return Mapper.Map<Contact, ContactView>(contact);
}
为什么转换为模型(ConvertToContactModel)方法不起作用??