C#C
C#3y ago
Henriquee

❔ Mapping error

Hello, I have a crud application in ASP.NET and I need to add a new selectList, the options come from the db, on the add screen I managed to implement it smoothly, but on the update screen it breaks my application claiming that it cannot map, but my AddVehicleDto is the same as my UpdateVehicleDto, apart from the ID of course, and it only complains about this new attribute that I include,
my mappers:
// code here
 using Ambipar.Response.Modules.Vehicles.Core.Entities;
using Ambipar.Response.Modules.Vehicles.Shared.Dtos;
using AutoMapper;

namespace Ambipar.Response.Modules.Vehicles.Application.Mappers
{
    public class DomainToDtoMappingProfile : Profile
    {
        public DomainToDtoMappingProfile()
        {
            CreateMap<Vehicle, UpdateVehicleDto>()
                .ForMember(dest => dest.Id, m => m.MapFrom(src => src.Id));
               


            CreateMap<Vehicle, PagedVehicleDto>()
                 .ForMember(dest => dest.Id, m => m.MapFrom(src => src.Id));
        }
    }
}

using Ambipar.Response.Modules.Vehicles.Core.Entities;
using Ambipar.Response.Modules.Vehicles.Shared.Dtos;
using AutoMapper;

namespace Ambipar.Response.Modules.Vehicles.Application.Mappers
{
    public class DtoToDomainMappingProfile : Profile
    {
        public DtoToDomainMappingProfile()
        {
            CreateMap<AddVehicleDto, Vehicle>();
            CreateMap<UpdateVehicleDto, Vehicle>();
                

        }
    }
}
Sem_titulo.png
Was this page helpful?