示例#1
0
        public DataConverter()
        {
            mapperConfiguration = new MapperConfiguration(c =>
            {
                c.CreateMap <Department, DepartmentModel>();
                c.CreateMap <Position, PositionModel>();

                c.CreateMap <Employee, EmployeeModel>()
                .ForMember(d => d.DayOfBirth, o => o.MapFrom(s => GenerationHelper.ToStringByFormatter(s.DayOfBirth, GenerationFormatter.StandardFormatter)))
                .ForMember(d => d.JoinedDate, o => o.MapFrom(s => GenerationHelper.ToStringByFormatter(s.JoinedDate, GenerationFormatter.StandardFormatter)))
                .ForMember(d => d.LeftDate, o => o.MapFrom(s => GenerationHelper.ToStringByFormatter(s.LeftDate, GenerationFormatter.StandardFormatter)))
                .ForMember(d => d.CreatedDate, o => o.MapFrom(s => GenerationHelper.ToStringByFormatter(s.CreatedDate, GenerationFormatter.StandardFormatter)))
                .ForMember(d => d.UpdatedDate, o => o.MapFrom(s => GenerationHelper.ToStringByFormatter(s.UpdatedDate, GenerationFormatter.StandardFormatter)))
                .ForMember(d => d.Department, o => o.MapFrom(s => s.Department))
                .ForMember(d => d.Position, o => o.MapFrom(s => s.Position));
            });

            mapper = new Mapper(mapperConfiguration);
        }