Skip to content

Instantly share code, notes, and snippets.

@Pierry
Created October 22, 2014 11:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pierry/a0ca1ca54a7b63cf2104 to your computer and use it in GitHub Desktop.
Save Pierry/a0ca1ca54a7b63cf2104 to your computer and use it in GitHub Desktop.
AutoMapper
public class AutoMapperConfig
{
public static void RegisterMappings()
{
Mapper.Initialize(c =>
{
c.AddProfile<DomainToViewModelMappingProfile>();
c.AddProfile<ViewModelToDomainMappingProfile>();
});
}
}
public class DomainToViewModelMappingProfile : Profile
{
public override string ProfileName
{
get { return "ViewModelToDomainMappings"; }
}
protected override void Configure()
{
Mapper.CreateMap<UserViewModel, User>();
}
}
public class ViewModelToDomainMappingProfile : Profile
{
public override string ProfileName
{
get { return "DomainToViewModelMappings"; }
}
protected override void Configure()
{
Mapper.CreateMap<User, UserViewModel>();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment