Boa*_*rge 7 c# implicit-cast automapper implicits
Mapper Automap:
Mapper.CreateMap<ObjectType1, ObjectType2>()
.ForMember(o1 => o1.PropName, mapper => mapper.MapFrom(o2 => o2.Prop2Name));
Mapper.Map(object1, object2);
Run Code Online (Sandbox Code Playgroud)
隐含运算符:
public static implicit operator Object1(Object2 o2)
{
Object1 o1 = new Object2();
//Mapping code here...
return o1;
}
Run Code Online (Sandbox Code Playgroud)