Skip to content

Generic class mapping with inheritance #789

Description

@luczito

I am in the process of refactoring a project from automapper to mapster.
I have run into an issue with mapping configs for generic classes e.g.

CreateMap(typeof(derivedDto<>), typeof(derivedDomain<>))
        .IncludeBase(typeof(baseDto), typeof(baseDomain)
        .ReverseMap();

As far as i can tell i can create a config for the base class via mapster as:

TypeAdapterConfig.GlobalSettings.ForType(typeof(derivedDto<>), typeof(derivedDomain<>))
    .Map("value", "Value");

But i (as far as i can tell) can not use .Include or .Inherits to include the inheritance information in the mappings.

Is this possible somehow or do i need to create a custom mapper to achieve this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions