标签:http creat tps oid bsp static blog https model1
1.注册
/// <summary>
/// AutoMapper 注册
/// </summary>
public class AutoMapperConfig
{
/// <summary>
///
/// </summary>
public static void Config()
{
Mapper.Initialize(m =>
{
m.CreateMap<Model1, Model2>();
});
}
}
2.使用
实体中使用 [MapTo("")]特性来对属性进行映射
Model2 newModel = Mapper.Map<Model1, Model2>(model);
详细参考:https://www.cnblogs.com/ZaraNet/p/10000311.html
.net AutoMapper(对象与对象之间的映射器) 的简单使用
标签:http creat tps oid bsp static blog https model1
原文地址:https://www.cnblogs.com/zhang1f/p/11666894.html