Constant and generated values
Constant values
To map a constant value to a member or a constructor parameter MapValue
can be used.
Make sure the value exactly matches the target type.
- Declaration
- Generated code
[MapValue(nameof(CarDto.SourceSystem), "C1")]
public partial CarDto Map(Car car);
target.SourceSystem = "C1";
Method generated values
To map a method generated value to a member or a constructor parameter MapValue
can be used.
Make sure the return type exactly matches the target type.
- Declaration
- Generated code
[MapValue(nameof(CarDto.SourceSystem), Use = nameof(GetSourceSystem))]
public partial CarDto Map(Car car);
string GetSourceSystem() => "C1";
target.SourceSystem = GetSourceSystem();
This also works for constructor parameters.