Reputation: 6917
Steps:
IMapper.map(viewModel, entity)
Because I'm providing a destination value to the map, is it possible to check that destination value for PreConditions?
Something like
.ForMember(x => x.Id, opt => {
opt.PreCondition((src, desintation) => destination.Id == null);
opt.MapFrom(src => Guid.NewGuid());
}
Is that possible? Maybe there's a better approach?
Upvotes: 2
Views: 2058
Reputation: 6917
Found it
.ForMember(dest => dest.EditedBy, opt => {
opt.PreCondition((src, dest, context) => dest.Id != Guid.Empty);
opt.MapFrom(src => Guid.NewGuid());
});
Upvotes: 2