Map base interface of source property to a class #319
-
I want to map source property with a base interface to a class. Given source: public class Dto {
public ISubDto Sub { get; }
}
public interface ISubDto : ISubFragment {
}
public interface ISubFragment {
public int Id { get; }
}
public class Model {
public SubModel Sub { get; set; }
}
public class SubModel {
public int Id { get; set; }
} Can I configure Mapperly to map There is a workaround via proxy methods, but it would be nice if Mapperly could detect this case: [Mapper]
public static partial class DtoMapper {
public static partial Model ToModel(this Dto source);
public static partial SubModel ToSubModel(this ISubFragment source);
private static SubModel MapToSubModel(ISubDto source) => ToSubModel(source);
} |
Beta Was this translation helpful? Give feedback.
Answered by
latonz
Apr 11, 2023
Replies: 1 comment 2 replies
-
This should just work, just remove the |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
latonz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should just work, just remove the
ToSubModel
andMapToSubModel
methods from the mapper.