Hello, I wrote my first API today and I used AutoMapper. I have a simple clarification question about the bolded line of code here:
I am aware that Mapper.Map is an AutoMapper function which is mapping my domain model to my Data Transfer Object (I wrote all of this code from scratch earlier), but I'm slightly confused on this syntax...
Is this basically pulling all of the data in my Movies table out of the database and then taking it and inserting the values into my DTO's properties and then returning those Dto properties to the client all in one step??? I'm guessing that is what it is doing but I'm not 100% sure. Sorry for the ignorance, I've only been coding since May but am excited to have made my first API!
public IEnumerable<MoviesDto> GetMovies()
{
return _context.Movies.ToList().Select(Mapper.Map<Movie, MoviesDto>);//Gives MoviesDto values associated with the domain class
}
I am aware that Mapper.Map is an AutoMapper function which is mapping my domain model to my Data Transfer Object (I wrote all of this code from scratch earlier), but I'm slightly confused on this syntax...
Is this basically pulling all of the data in my Movies table out of the database and then taking it and inserting the values into my DTO's properties and then returning those Dto properties to the client all in one step??? I'm guessing that is what it is doing but I'm not 100% sure. Sorry for the ignorance, I've only been coding since May but am excited to have made my first API!