Skip to content

Instantly share code, notes, and snippets.

@tuannguyenssu
Created August 5, 2019 13:32
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/31ebe9dde6d0beb91e812196d43a49ad to your computer and use it in GitHub Desktop.
Save tuannguyenssu/31ebe9dde6d0beb91e812196d43a49ad to your computer and use it in GitHub Desktop.
using AutoMapper;
using AutoMapperTest.Models;
namespace AutoMapperTest.Mappings
{
public class MappingProfile : Profile {
public MappingProfile() {
// Đưa hết các cấu hình bạn muốn map giữa các object vào đây
// Thuộc tính FullName trong UserViewModel được kết hợp từ FirstName và LastName trong User
CreateMap<User, UserViewModel>().ForMember(d => d.FullName, o => o.MapFrom(s => $"{s.FirstName} {s.LastName}"));
CreateMap<UserViewModel, User>();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment