Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using AutoMapper;
using Microsoft.AspNetCore.Mvc;
namespace automapper_sample.Controllers
public class StudentController : Controller
private readonly IMapper _mapper;
public StudentController(IMapper mapper)
_mapper = mapper;
// GET: api/<controller>
public Student Get()
StudentDTO studentDTO = new StudentDTO()
Name = "Student 1",
Age = 25,
City = "New York"
return _mapper.Map<Student>(studentDTO);
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.