MapsterMapper / Mapster

A fast, fun and stimulating object to object Mapper
MIT License
4.38k stars 331 forks source link

Mapping hierarchies not working #701

Open MitchellW-DWL opened 6 months ago

MitchellW-DWL commented 6 months ago

I've managed to isolate and replicate my issue in a couple of unit tests, can see here: https://github.com/MitchellW-DWL/MapsterIssue

But I can also see this case should be covered by: https://github.com/MapsterMapper/Mapster/blob/master/src/Mapster.Tests/WhenIncludeDerivedClasses.cs

When I have an object which derives from ParentEntity and map it too ParentModel I expect it to be appropriately typed with the Include options, i.e. if the entity is ChildEntityA then the result should be ChildModelA and same for ChildEntityB & ChildModelB

Can see in my example this works as expected when you're mapping List<T> -> List<U> but not for the corresponding T -> U