Nullable Support #578
-
If we had an |
Beta Was this translation helpful? Give feedback.
Answered by
TimothyMakkison
Jul 19, 2023
Replies: 1 comment 6 replies
-
Hey, thanks for using mapperly. Do you have a simple example you could share or possibly the generated code? Mapperly should detect nullable members and generate conditional mapping code. Example nullable:[Mapper]
public static partial class Mapper
{
public static partial EmployeePositionDto Map(EmployeePosition car);
}
public class EmployeePosition { public PayRate? PayRate { get; set; } }
public class EmployeePositionDto { public PayRateDto PayRate { get; set; } }
public class PayRate {}
public class PayRateDto {} Generated codepublic static partial global::Riok.Mapperly.Sample.EmployeePositionDto Map(global::Riok.Mapperly.Sample.EmployeePosition car)
{
var target = new global::Riok.Mapperly.Sample.EmployeePositionDto();
if (car.PayRate != null)
{
target.PayRate = MapToPayRateDto(car.PayRate);
}
return target;
}
private static global::Riok.Mapperly.Sample.PayRateDto MapToPayRateDto(global::Riok.Mapperly.Sample.PayRate source)
{
var target = new global::Riok.Mapperly.Sample.PayRateDto();
return target;
} |
Beta Was this translation helpful? Give feedback.
6 replies
Answer selected by
AmalDarKhalil
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, thanks for using mapperly.
Do you have a simple example you could share or possibly the generated code? Mapperly should detect nullable members and generate conditional mapping code.
If you've recently added mapperly then sometimes restarting your ide can help.
Example nullable:
Generated code