In my application i have to use mapping.
Structure of my Source object is
public class SourceContract
{
public string ContractNo {get; set;}
public string ContractDescription {get; set;}
List<SourceSalary> SourceSalaries {get;set;}
}
Source salary is
public class SourceSalary
{
public string SalaryNo {get; set;}
public int SalaryFixed {get; set;}
}
Structure of Destination Object is
public class DestinationContract
{
public string DestinationContractNo {get; set;}
public string DestinationDescription {get; set;}
List<DestinationSalary> DestinationSalaries {get;set;}
}
Destination Salary is
public class DestinationSalary
{
public string DestinationSalaryNo {get; set;}
pubbic int DestinationSalaryFixed {get; set;}
}
Now I am using two mappers
AutoMapper.Mapper.CreateMap<
SourceContract, DestinationContract>()
.ForMember(dest => dest.DestinationContractNo, opt => opt.MapFrom(src => src.ContractNo))
.ForMember(dest => DestinationDescription, opt => opt.MapFrom(src => src.ContractDescription))
And
AutoMapper.Mapper.CreateMap<
SourceSalary, DestinationSalary>()
.ForMember(dest => dest.DestinationSalaryNo, opt => opt.MapFrom(src => src.SalaryNo))
.ForMember(dest => DestinationSalaryFixed, opt => opt.MapFrom(src => src.SalaryFixed))
I want to use only one Mapper
I am not able to use nested mapping because SourceContract contains List and DestinationContract also contains List
Is there any way that I can map in One Mapper?? something like nested mapping
P.S- I cannot change the names or structure of nethier destination nor Source.