Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
AutoMapperProfile.cs with conditional mappings
using AutoMapper;
namespace automapper_sample
public class AutoMapperProfile : Profile
public AutoMapperProfile()
CreateMap<StudentDTO, Student>()
.ForMember(dest => dest.City, opt => opt.MapFrom(src => src.CurrentCity))
.ForMember(dest => dest.IsAdult, opt => opt.MapFrom(src => src.Age > 18 ? true : false));
CreateMap<AddressDTO, Address>();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.