I have a separate classes for mapping between source and destination. For e.g.
RegistrationMapping:
public class RegistrationMapping
{
public static void Map(IProfileExpression profile)
{
profile.CreateMap<DB_Registration, Registration>()
.ForMember(x => x.EMP_ID, map => map.MapFrom(c => c.employeeID))
.ForMember(x => x.MOB_NO, map => map.MapFrom(c => c.Mobile))
.ForMember(x => x.EMAIL_ID, map => map.MapFrom(c => c.EmailID))
}
}
In a similar fashion, I have classes for other mappings as well.
Now in my repository, I want to use like this,
var config = new MapperConfiguration(cfg => cfg.AddProfile(/*RegistrationMapping goes here*/)); // But I want to add it in a generic way.
var mappedConfigurations = config.GetAllTypeMaps(); // This line of code is needed for my other purpose(get unmapped properties)
Any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire