IntentArchitect / Support

A repository dedicated to handling issues and support queries
3 stars 0 forks source link

Dto Mapping configuration #95

Closed morne-insight closed 3 months ago

morne-insight commented 3 months ago

Ask a question

Hey guys.

I have recently upgraded IA to the latest version of 4.2.9.

Since I've done this AI is trying to update my DTO mappings from:

profile.CreateMap<CPAGroup, CPAGroupDto>();

to

profile.CreateMap<Apple, AppleDto>()
   .ForMember(d => d.Id, opt => opt.MapFrom(src => src.BaseOption.BaseEntity.Id))
    .ForMember(d => d.Name, opt => opt.MapFrom(src => src.BaseOption.Name))
    .ForMember(d => d.IsDisabled, opt => opt.MapFrom(src => src.BaseOption.BaseEntity.IsDisabled));

The above code is giving the following build error: Severity Code Description Project File Line Suppression State

Error CS1061 'Apple' does not contain a definition for 'BaseOption' and no accessible extension method 'BaseOption' accepting a first argument of type 'Apple' could be found (are you missing a using directive or an assembly reference?)

If I refactor to the following everything works.

profile.CreateMap<Apple, AppleDto>()
    .ForMember(d => d.Id, opt => opt.MapFrom(src => src.Id))
    .ForMember(d => d.Name, opt => opt.MapFrom(src => src.Name))
    .ForMember(d => d.IsDisabled, opt => opt.MapFrom(src => src.IsDisabled));

When I look at my Git Changes I can see the following:

from: <mappedClass> to <mappedClass isRoot="true"/>

All references to the BaseOption and BaseEntity have changed the "specialization" from "Generalization" to "Generalization Target End". (BaseOption and BaseEntity are marked as Abstract in the Entity Designer.)

from: <target id="9db21c47-2708-4d0d-9634-0319d9f80e74" name="BaseOption" type="association" specialization="Generalization" /> to: <target id="9db21c47-2708-4d0d-9634-0319d9f80e74" name="BaseOption" type="association" specialization="Generalization Target End" />

Please let me know if you have any idea how to resolve this.

Thanks

joelsteventurner commented 3 months ago

Hi @morne-insight

Look at the issue I recall this being an issue on one of the older versions of our Intent.Application.Dtos.AutoMapper module, can I suggest updating this module and seeing if that helps?

morne-insight commented 3 months ago

Hi @joelsteventurner

Spot on, I updated all the modules and it has resolved the issue.