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); }
public void CreateMappings(AutoMapper.Profile configuration) { configuration.CreateMap <CreateIdentityQuery, Domain.Identity.Identity>(); }