Mapperly Help how to map child CreateDto's?

I have a problem that I cannot solve at the moment I still don't know how to map the properties of the child CreateDto's. Mapperly documentation I didn't find anything about it or just don't understand it. If someone can guide me or help me map this so I can do this to my other entities. MapperProfile: https://pastebin.com/nPFx5uEF This is the DTO I am refering to: https://pastebin.com/s48iuVfk Entity: https://pastebin.com/bcDuveLY
Pastebin
using RestauraceNET8.Data.EF.BL.DTO.RestauraceDTO.ObjednavkaPolozky...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin
using RestauraceNET8.Data.EF.BL.DTO.RestauraceDTO.ObjednavkaPolozky...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin
namespace RestauraceNET8.Data.EF.DAL.Entities.Restaurace;public cla...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
1 Reply
Core
Core2w ago
Mapperly allows custom mappers, which are not partial, so they are manually created. First of all, you should create a partial mapper, and use
c#
[MapperIgnoreSource(nameof(RestauraceObjednavkaPolozky.RestauraceObjednavkaPridavky))]
c#
[MapperIgnoreSource(nameof(RestauraceObjednavkaPolozky.RestauraceObjednavkaPridavky))]
This way no mapping will be generated for the specified property. https://mapperly.riok.app/docs/configuration/mapper/#ignore-properties--fields This partial mapper should be declared as private, since it will be used by the public one. What you are looking for is called after mapping. https://mapperly.riok.app/docs/configuration/before-after-map/ Exmaple
c#
[Mapper]
public partial class CarMapper
{
// This is where you apply the annotation to ignore specific properties
private partial CarDto CarToCarDto(Car car);

public CarDto MapCarToCarDto(Car car)
{
var dto = CarToCarDto(car);

// custom mapping goes here, (e.g. the properties that are not part of the generated private mapper)

return dto;
}
}
c#
[Mapper]
public partial class CarMapper
{
// This is where you apply the annotation to ignore specific properties
private partial CarDto CarToCarDto(Car car);

public CarDto MapCarToCarDto(Car car)
{
var dto = CarToCarDto(car);

// custom mapping goes here, (e.g. the properties that are not part of the generated private mapper)

return dto;
}
}
Before / after map | Mapperly
Run custom logic before or after the generated mapping.
Mapper configuration | Mapperly
Define a mapper with Mapperly.

Did you find this page helpful?