Skip to content

Instantly share code, notes, and snippets.

@tuannguyenssu
Created August 5, 2019 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuannguyenssu/71995a9bdc7b9cf096a09a682d21f701 to your computer and use it in GitHub Desktop.
Save tuannguyenssu/71995a9bdc7b9cf096a09a682d21f701 to your computer and use it in GitHub Desktop.
// Source Order -> Destination OrderDto
var config = new MapperConfiguration(cfg => cfg.CreateMap<Order, OrderDto>());
// Khởi tạo mapper
//var mapper = config.CreateMapper();
// Hoặc
var mapper = new Mapper(config);
// Kiểm tra cấu hình. Nếu có lỗi sẽ văng Exception (Development mode)
config.AssertConfigurationIsValid();
// Tạo đối tượng mới từ đối tượng cũ thông qua mapper
OrderDto dto = mapper.Map<OrderDto>(order);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment