Skip to content

Mapping from different source types to same target type (different, not multiple concurrent sources) #314

@AllanMichaelsen

Description

@AllanMichaelsen

Say I have a class that is mapping from an EF Core Entity, but I also want to have an alternate route to the same target.

From:

public partial class UnitEntity : ModifiedByBaseEntity

or

public partial class UnitDto : FacetsModifiedByBaseDto;

To:

[Facet(typeof(UnitDto),
    Include =
    [
        nameof(UnitEntity.Name)
    ])]
public partial class UnitDropDownDto : FacetsModifiedByBaseDto;

[Facet(typeof(UnitEntity),
    Include =
    [
        nameof(UnitEntity.Name)
    ])]
public partial class UnitDropDownDto : FacetsModifiedByBaseDto;

I could make a manual partial class and add the constructor for it and all the needed projection and such, but that would take away from the idea of automation and would make it cumbersome if changing the target class.

Is there a way to have multiple paths of mapping to the same target?

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions