Replies: 1 comment 1 reply
-
Mapperly attributes are alyways applied to the parameter / return type of mapping methods. This should work: [Mapper]
public static partial class CarMapper
{
public static partial IQueryable<CarDto> ProjectToDto(this IQueryable<Car> car);
[MapperIgnoreTarget(nameof(CarDto.Tires))]
private static partial CarDto ToDto(this Car car);
} Mapperly uses the configuration of |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the bug
When creating a new mapper class, if you only have an IQueryable mapping method, the MapperIgnore attributes are not honoured and will continue to generate the properties. If you add the same mapping method without the non-IQueryable, it will properly generate both the IQueryable and non-IQueryable ignored properties.
To Reproduce
Steps to reproduce the behaviour:
IQueryable<CarDto> ProjectToDto(this IQueryable<Car> car);
[MapperIgnoreTarget(nameof(CarDto.Tires))]
3a. The generated code will still have the Tires property
CarDto ToDto(this Car car);
[MapperIgnoreTarget(nameof(CarDto.Tires))]
5a. The generated code will correctly ignore the Tires property on both mapping methods
Expected behavior
At 3a, the generated code should ignore the Tires property regardless of whether a non-IQueryable mapping method is present or not.
Code snippets
The models and dtos are the same as the ones provided in the docs. The mapping class is as followed as of step 3a:
Here is the mapping class as of step 5a:
Environment:
Beta Was this translation helpful? Give feedback.
All reactions