Created
October 7, 2018 18:00
-
-
Save icebeam7/554c629aa885af921497c3a00ff238da to your computer and use it in GitHub Desktop.
StoreWebAPI: AutoMapperConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using AutoMapper; | |
using StoreWebApi.Models; | |
namespace StoreWebApi.DTOs | |
{ | |
public class AutoMapperConfiguration | |
{ | |
public static void Configure() | |
{ | |
Mapper.Initialize(cfg => | |
{ | |
cfg.CreateMap<Customer, CustomerDTO>() | |
.ForMember(x => x.CustomerOrder, o => o.Ignore()) | |
//.ForMember(x => x.Nombre, o => o.MapFrom(s => s.FirstName)) | |
.ReverseMap(); | |
cfg.CreateMap<CustomerOrder, CustomerOrderDTO>() | |
.ForMember(x => x.OrderDetail, o => o.Ignore()) | |
.ReverseMap(); | |
cfg.CreateMap<Employee, EmployeeDTO>() | |
.ReverseMap(); | |
cfg.CreateMap<OrderDetail, OrderDetailDTO>() | |
.ReverseMap(); | |
cfg.CreateMap<OrderStatus, OrderStatusDTO>() | |
.ForMember(x => x.CustomerOrder, o => o.Ignore()) | |
.ReverseMap(); | |
cfg.CreateMap<Product, ProductDTO>() | |
.ForMember(x => x.OrderDetail, o => o.Ignore()) | |
.ReverseMap(); | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment