0
在这种情况下,我无法关注wiki。我想使用Automapper 5.2。我无法找到结束示例的简单结尾,它显示了具有上下文的可靠配置。根据上下文,我的意思是你把配置文件放在哪里以及静态和实例api之间有什么区别?设置Automapper 5.1
我检出了DNRTV下载,但它处理1.0版本。
如何设置此包?我有一个名为Client的模型,如下所示。
public class Client : IEntityBase
{
public Client()
{
Jobs = new List<Job>();
}
public int Id { get; set; }
public int ClientNo { get; set; }
public bool Company { get; set; }
public string CompanyName { get; set; }
public string ClientFirstName { get; set; }
public DateTime DeActivated { get; set; }
public bool Activity { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateUpdated { get; set; }
public int? StateId { get; set; }
public State State { get; set; }
public int CreatorId { get; set; }
public User Creator { get; set; }
public ICollection<Job> Jobs { get; set; }
}
和ClientViewModel像这样:
public class ClientViewModel
{
public int Id { get; set; }
public int ClientNo { get; set; }
public bool Company { get; set; }
public string CompanyName { get; set; }
public string ClientFirstName { get; set; }
public DateTime DeActivated { get; set; }
public bool Activity { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateUpdated { get; set; }
public int? StateId { get; set; }
public int CreatorId { get; set; }
public int[] Jobs { get; set; }
}
我不能确定如何设置AutoMapper了关于配置。也就是说,他们谈论的是一个global.asax文件,而我正在使用aspnet core ..没有Global.asax文件..
如果有什么,你会在Startup.cs文件中放什么。
鉴于上述这两个文件,我需要做些什么才能将Automapper与它们结合使用?
Regards
一些具体的内容添加到
Startup.cs ConfigureServices
方法4.调用扩展方法。 。非常感谢你..将投票这!!我有一个问题。“.ReverseMap()”做什么? – si2030
它做了双向映射像上面的例子客户端到ClientViewModel和ClientViewModel到客户端 – Ahmar
我已经投了这个。 – si2030