Skip to content

Instantly share code, notes, and snippets.

@tuannguyenssu
Created August 5, 2019 13:33
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/1fcdc5e76c1b72dfd36533a6d4b66251 to your computer and use it in GitHub Desktop.
Save tuannguyenssu/1fcdc5e76c1b72dfd36533a6d4b66251 to your computer and use it in GitHub Desktop.
public void ConfigureServices(IServiceCollection services)
{
// Cấu hình AutoMapper - Cách 1
var mappingConfig = new MapperConfiguration(mc =>
{
mc.AddProfile(new MappingProfile());
});
mappingConfig.AssertConfigurationIsValid();
IMapper mapper = mappingConfig.CreateMapper();
services.AddSingleton(mapper);
// Cấu hình AutoMapper - Cách 2 cũ hơn
// Mapper.Initialize(cfg => cfg.AddProfile<MappingProfile>());
// services.AddAutoMapper();
services.AddControllersWithViews();
services.AddRazorPages();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment