예제 #1
0
        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);
        }
예제 #2
0
        void IConfiguration.AddProfile(Profile profile)
        {
            _profiles.AddOrUpdate(profile.ProfileName, profile, (s, configuration) => profile);

            profile.Initialize(this);
        }
예제 #3
0
 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>()));
 }