Skip to main content

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.

[MapValue(nameof(CarDto.SourceSystem), "C1")]
public partial CarDto Map(Car car);

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.

[MapValue(nameof(CarDto.SourceSystem), Use = nameof(GetSourceSystem))]
public partial CarDto Map(Car car);

string GetSourceSystem() => "C1";

This also works for constructor parameters.