Make nullables dublicates of the mappings (And ignore settings of my mapper)
See original GitHub issueFollowing the documentation - i made internal mapper to convert properties of the object:
[Mapper(UseDeepCloning = true)]
public static partial class PortfolioMapper
{
public static partial GetPortfolioResponseDto ToGetDto(this Portfolio source);
[MapperIgnoreSource(nameof(Agreement.Portfolios))]
[MapperIgnoreSource(nameof(Agreement.Client))]
private static partial GetAgreementResponseDto ToGetAgreementResponseDto(Agreement source);
[MapperIgnoreSource(nameof(Client.Agreements))]
private static partial GetClientResponseDto ToGetClientResponseDto(Client source);
}
Code Generated includes “?” for nullables for the Portfolio class
But also for the Agreement class where i configured ignore settings for the Client property:
So it uses nullable version of code-generated mapper and doesn’t pick up my configuration.
To Reproduce So I’ve tried to reproduce the bug, but in small project it works fine - it doesn’t create nullable duplicates.
Environment (please complete the following information):
- Mapperly Version: 2.6
- Target Framework: net7.0
- OS: Windows10
Original Classes:
public class Agreement
{
[Key]
public int AgreementId { get; set; }
public Client Client { get; set; }
public string Code { get; set; }
public List<Portfolio> Portfolios { get; set; }
public DateTimeOffset Date { get; set; }
public DateTimeOffset? TerminationDate { get; set; }
public bool IsDeleted { get; set; }
}
public sealed class GetAgreementResponseDto
{
public int AgreementId { get; init; }
public GetClientResponseDto Client { get; init; }
public string Code { get; init; }
public DateTimeOffset Date { get; init; }
public DateTimeOffset TerminationDate { get; init; }
}
public sealed class GetPortfolioResponseDto
{
public int PortfolioId { get; init; }
public GetAgreementResponseDto Agreement { get; init; }
public string Code { get; init; }
public DateTimeOffset Date { get; init; }
public DateTimeOffset TerminationDate { get; init; }
}
public class Portfolio
{
[Key]
public int PortfolioId { get; set; }
public Agreement Agreement { get; set; }
public string Code { get; set; }
public DateTimeOffset Date { get; set; }
public DateTimeOffset? TerminationDate { get; set; }
public bool IsDeleted { get; set; }
}
Issue Analytics
- State:
- Created 8 months ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
AutoMapper MapFrom can't take null values [duplicate]
It has to be possible to assign a null value. How can I fix it so that I can assign null values to...
Read more >Automapper Update entity field if not null fails ...
Ignore does two things - skips mapping if the members match, and skip the member for configuration validation. If you need to skip...
Read more >Scaffold mapping on non-nullable bool #10840
The columns are not null and have a default in the DB. Can't the scaffold be smart enough to allow me to set...
Read more >Fluent API - Configuring and Mapping Properties and Types
In this article. Model-Wide Settings; Property Mapping; Type Mapping; Model Used in Samples. When working with Entity Framework Code First the ...
Read more >Chapter 2. Mapping Entities
The name property is mapped to the flight_name column, which is not nullable, has a length of 50 and is not updatable (making...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found a bug related to init only properties and nullable. should be fixed with #257.
🎉 This issue has been resolved in version 2.7.0 🎉
The release is available on:
v2.7.0
Your semantic-release bot 📦🚀