-
Is it possible to change the name of a mapped property when using a constructor? In the code below it is not possible to use the mapper for class A -> class D #define USE_D
using Riok.Mapperly.Abstractions;
var a = new A() { Name = "Test"};
Console.WriteLine(ABMapper.MapAToB(a));
Console.WriteLine(ACMapper.MapAToC(a));
#if USE_D
Console.WriteLine(ADMapper.MapAToD(a));
#endif
record A
{
public string Name { get; set; } = string.Empty;
}
record B
{
public B(string name)
{
Name = name;
}
public string Name { get; }
}
[Mapper]
static partial class ABMapper
{
public static partial B MapAToB(A a);
}
record C
{
public string TheName { get; set; } = string.Empty;
}
[Mapper]
static partial class ACMapper
{
[MapProperty("Name", "TheName")]
public static partial C MapAToC(A a);
}
#if USE_D
class D
{
public D(string theName)
{
TheName = theName;
}
public string TheName { get; }
}
[Mapper]
static partial class ADMapper
{
[MapProperty("Name", "TheName")]
public static partial D MapAToD(A a);
}
#endif |
Beta Was this translation helpful? Give feedback.
Answered by
latonz
Jan 22, 2023
Replies: 1 comment 1 reply
-
Thank you for opening the discussion. I think what you need is just beeing implemented in #239. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
newell-ma
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for opening the discussion. I think what you need is just beeing implemented in #239.