Skip to content

Instantly share code, notes, and snippets.

@tuannguyenssu tuannguyenssu/Startup.cs Secret
Created Aug 5, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.