lundi 6 avril 2020

How can get data from an object and set to another object with mapper in c#

I want to create a method like ModelConvert<>(Tfrom fromModel, Tto toModel, string mapperFilePath) To get data from Tfrom(generic) and set to Tto(generic). The field for mapping as below in Mapper file:

Name=Name
Age=age
Address.Country.CountryName=CountryName

Tto example: public class PersonModel { public string Name { get; set; } public string Age { get; set; } public string CountryName { get; set; } }

Tfrom excample:

public class PersonDTO
{
    public string Name { get; set; }
    public int Age { get; set; }
    public AddressDetail Address { get; set; }

}




Aucun commentaire:

Enregistrer un commentaire