コード例 #1
0
        public Flattening()
        {
            _user = new User
            {
                Name = "Anakin"
            };

            _ticket = new Ticket
            {
                User = _user
            };

            _article = new Article
            {
                Name  = "Tabac",
                Price = 99.99m
            };

            _ticket.AddTicketLineItem(_article, 8);

            _mapper = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Ticket, TicketDto>()
                .ForMember(x => x.CustomerName, x =>
                {
                    x.Condition(e => e.User is not null);
                    x.MapFrom(e => e.User !.Name);
                })
                .ReverseMap();
            })