Base solution for your next web application
Open Closed

Different DTO ? #2897


User avatar
0
liam1983 created

i had a WebApi Project but I need in the list much less data then in the detail view of an item, what's more correct:

GetAll returns a different DTO or GetAll for the list is in an own controller only with the methods needed


1 Answer(s)
  • User Avatar
    0
    th3monk3y created

    If I am understanding you correctly, what you want to do is create a DTO with the data you need and then use AutoMapper to map the returned values from "GetAll" to your DTO.

    Look at the existing examples in the boilerplate code. You will need create a mapping in your Application module.

    Configuration.Modules.AbpAutoMapper().Configurators.Add(mapper =>
                {
                    //Add your custom AutoMapper mappings here...
                    //mapper.CreateMap<,>()
                    mapper.CreateMap<CustomerDto, Customer>();
                });