Skip to content

Instantly share code, notes, and snippets.

@brunomartinspro
Created June 11, 2018 18:34
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 brunomartinspro/4a717bb8438bdd4accbbf8ac399089bf to your computer and use it in GitHub Desktop.
Save brunomartinspro/4a717bb8438bdd4accbbf8ac399089bf to your computer and use it in GitHub Desktop.
Configure AutoMapper in ASP.NET Core
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> ();
}
}
}
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