C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,198 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I wonder if there is a way to set Pin to Serial if Pin is null.
CreateMap<CouponDto, Coupon>()
.ForMember(dest => dest.Pin, src => src.NullSubstitute("-"))
.ForMember(dest => dest.Serial, src => src.NullSubstitute("-"));
you can use IValueResolver to implement custom mapping
public class CustomPropertyMapping
: IValueResolver<Source, Destination, int>
{
public decimal Resolve(Source source,
DestinationDto destination, int value,
ResolutionContext context)
{
if (condition met)
return property1;
else
return property2
}
}
and in configuration
CreateMap>Source, DestinationDto>()
.ForMember(dest => dest.property,
source => source.MapFrom<CustomPropertyMapping>())
for more details on see custom property mapping using AutoMapper