I have a simple model like this one:
public class Order{ public int Id { get; set; } ... ... public IList<OrderLine> OrderLines { get; set; } } public class OrderLine{ public int Id { get; set; } public Order ParentOrder { get; set; } ... ... }
What I do with Automapper is this:
Mapper.CreateMap<Order, OrderDto>(); Mapper.CreateMap<OrderLine, OrderLineDto>(); Mapper.AssertConfigurationIsValid();
It throw an exception that says: "The property OrderLineDtos in OrderDto is not mapped, add custom mapping ..." As we use a custom syntax in our Domain and in our DomainDto, how I can specify that the collection OrderLineDtos in OrderDto corresponds to OrderLines in Order?
Thank you
C is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, and so on. C programming is an excellent language to learn to program for beginners. Our C tutorials will guide you to learn C programming one step at a time.
C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.
C, computer programming language developed in the early 1970s by American computer scientist Dennis M. Ritchie at Bell Laboratories (formerly AT&T Bell Laboratories).
It works in this way:
Mapper.CreateMap<Order, OrderDto>() .ForMember(dest => dest.OrderLineDtos, opt => opt.MapFrom(src => src.OrderLines)); Mapper.CreateMap<OrderLine, OrderLineDto>() .ForMember(dest => dest.ParentOrderDto, opt => opt.MapFrom(src => src.ParentOrder)); Mapper.AssertConfigurationIsValid();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With