public void CreateMappings(AutoMapper.Profile profile) { var mappingExpression = profile.CreateMap <TDto, TEntity>(); var mappingExpressionReverse = profile.CreateMap <TEntity, TDto>(); var dtoType = typeof(TDto); var entityType = typeof(TEntity); //Ignore any property of source (like Post.Author) that dose not contains in destination foreach (var property in entityType.GetProperties()) { if (dtoType.GetProperty(property.Name) == null) { mappingExpression.ForMember(property.Name, opt => opt.Ignore()); } } //foreach (var property in dtoType.GetProperties()) //{ // if (entityType.GetProperty(property.Name) == null) // mappingExpression.ForMember(property.Name, opt => opt.Ignore()); //} CustomMappings(mappingExpressionReverse); CustomMappingsReverse(mappingExpression); }
void IConfiguration.AddProfile(Profile profile) { _profiles.AddOrUpdate(profile.ProfileName, profile, (s, configuration) => profile); profile.Initialize(this); }
public void CreateMappings(AutoMapper.Profile configuration) { configuration.CreateMap <CreateIdentityQuery, Domain.Identity.Identity>(); }
public static CreateMultiLingualMapResult <TSource, TTranslation, TDestination> CreateMultiLingualMap <TSource, TTranslation, TDestination>(this Profile profile) where TTranslation : class, IMultiLingualTranslation where TSource : IHasMultiLingual <TTranslation> { return(new( profile.CreateMap <TSource, TDestination>().BeforeMap <AbpMultiLingualMapperAction <TSource, TTranslation, TDestination> >(), profile.CreateMap <TTranslation, TDestination>())); }