I have two objects request and response and they have few properties like below
public class Employee
{
public string Name{get;set;}
public Address EmployeeAddress{get;set;}
}
Address itself is a class with below properties
public class Address
{
public string Street{get;set;}
public string HouseNo{get;set;}
public List PhoneDetail{get;set;}
}
Now Phone is itself a class with below schema
public class phone
{
public string mobile {get;set;}
public string Home{get;set;}
}
This above is request object we have a response object having exactly same schema with all classes and properties are same Now I want to map them Like
Request.Name=Response.Name How to do that for all properties specially for Phone which is of type list .
Mark TaborPosted Oct 31, 2021, 6:23 AM
Sachin SinghPosted Oct 31, 2021, 4:26 AM
Srinivasan RamamoorthiPosted Oct 31, 2021, 3:25 AM
You can make use of Automapper
check this link https://www.c-sharpcorner.com/article/mapping-similar-objects-in-asp-net-core-2-0/