Created
June 11, 2018 18:34
-
-
Save brunomartinspro/4a717bb8438bdd4accbbf8ac399089bf to your computer and use it in GitHub Desktop.
Configure AutoMapper in ASP.NET Core
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 System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using AutoMapper; | |
using BrunoMartinsPro.Models.Report; | |
using BrunoMartinsPro.DTO.Report; | |
namespace BrunoMartinsPro.Config | |
{ | |
public class AutoMapperProfile : Profile | |
{ | |
/// <summary> | |
/// Config AutoMapper Mappings | |
/// </summary> | |
public AutoMapperProfile() | |
{ | |
CreateMap<ReportModel, ReportDTO>(); | |
CreateMap<ReportDTO, ReportModel> (); | |
} | |
} | |
} |
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
public void ConfigureServices(IServiceCollection services) | |
{ | |
//Register AutoMapper in class startup (from program.cs) | |
services.AddAutoMapper(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment