Exemple #1
0
        /// <summary>
        /// 属性名相同,属性类型不同,可进行转化;
        /// </summary>
        public static void AutpMapperSevevn()
        {
            Mapper.Initialize(x => x.AddProfile <UserTypeConverterProfile>());//可以在MVC中Global中一次性注册
            User user = new User()
            {
                Type = 1
            };
            UserDto6 dto = Mapper.Map <UserDto6>(user);

            Console.WriteLine("77777" + dto.Age + dto.Name2 + dto.NullText + dto.MoreParams + dto.Type);
        }
Exemple #2
0
        /// <summary>
        /// 满足某种条件进行映射
        /// </summary>
        public static void AutpMapperEight()
        {
            Mapper.Initialize(x => x.AddProfile <UserConditionProfile>());//可以在MVC中Global中一次性注册
            User user = new User()
            {
                Age  = 30,
                Type = 1
            };
            UserDto6 dto = Mapper.Map <UserDto6>(user);

            Console.WriteLine("8888" + dto.Age + dto.Name2 + dto.NullText + dto.MoreParams + dto.Type);
        }