-
-
Save tuannguyenssu/31ebe9dde6d0beb91e812196d43a49ad to your computer and use it in GitHub Desktop.
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 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