티스토리 뷰
using AutoMapper;
//using AutoMapper.Configuration;
//using AutoMapper.Execution;
//using AutoMapper.Features;
//using AutoMapper.Internal;
//using AutoMapper.Mappers;
public class ClsTarget
{
public string Name1 { get; set; }
public int Salary { get; set; }
public string Address { get; set; }
public string Department { get; set; }
}
public class ClsSource
{
public string Name { get; set; }
public int Salary { get; set; }
public string Address { get; set; }
public string Department { get; set; }
}
private void Form1_Load(object sender, EventArgs e)
{
// Source , Target
// var config = new MapperConfiguration(cfg => cfg.CreateMap());
// 프로퍼티 이름 변경해서 쓸 경우
var config = new MapperConfiguration(cfg => cfg.CreateMap().
ForMember(d=>d.Name1 , o=>o.MapFrom(s=>s.Name)));
var mapper = new Mapper(config);
ClsSource _ClsSource = new ClsSource();
_ClsSource.Name = "test0";
_ClsSource.Salary = 11;
_ClsSource.Address = "test1";
_ClsSource.Department = "test2";
ClsTarget _ClsTarget = mapper.Map(_ClsSource);
}