Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. private void ConfigureMap(IMapperConfigurationExpression config)
  2. {
  3. config.CreateMap<Product, ProductViewModel>()
  4. .ForMember(d => d.FullName, opt => opt.MapFrom(src => src.Name + src.SuName))
  5. .ForMember(d => d.Age, opt => opt.MapFrom(src => src.Vozrast));
  6. }
  7. //...
  8. //...
  9. //...
  10. // Где-то в другом месте
  11.  
  12. // Тут получаем IList<Product>
  13. var products = ProductRepository.GetAll();
  14. // Тут маппим их в IList<ProductViewModel>
  15. var productVMs = Mapper.Map<IList<ProductViewModel»(products);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement