Say I have one class that looks like this:
public class Person
{
public string Name {get; set;}
public int Number {get; set;}
}
You can use AutoMapper:
public Dog UsingAMR(Person prs)
{
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap();
});
IMapper mapper = config.CreateMapper();
return mapper.Map(prs);
}
Then you can easily:
Person ps = new Person {Name = "John", Number = 25};
Dog dog = UsingAMR(ps);
Just don't forget to install AutoMapper first from the package manager console as mentioned in the reference:
Then type the following command:
PM> Install-Package AutoMapper