Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Tentando executar o Get

Senhores, bom dia!

Quando tento executar o get no postman aparece a informação abaixo

AutoMapper.AutoMapperMappingException: Error mapping types.

Mapping types: List1 -> List1 System.Collections.Generic.List1[[FilmesApi.Models.Cinema, FilmesApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] -> System.Collections.Generic.List1[[FilmesApi.Data.Dtos.ReadCinemaDto, FilmesApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] ---> AutoMapper.AutoMapperMappingException: Error mapping types.

Mapping types: Cinema -> ReadCinemaDto FilmesApi.Models.Cinema -> FilmesApi.Data.Dtos.ReadCinemaDto

Type Map configuration: Cinema -> ReadCinemaDto FilmesApi.Models.Cinema -> FilmesApi.Data.Dtos.ReadCinemaDto

Destination Member: ReadEnderecoDto

---> AutoMapper.AutoMapperMappingException: Missing type map configuration or unsupported mapping.

Mapping types: EnderecoProxy -> ReadEnderecoDto Castle.Proxies.EnderecoProxy -> FilmesApi.Data.Dtos.ReadEnderecoDto

Destination Member: ReadEnderecoDto

at lambda_method123(Closure , Endereco , ReadEnderecoDto , ResolutionContext ) at lambda_method117(Closure , Object , List1 , ResolutionContext ) --- End of inner exception stack trace --- at lambda_method117(Closure , Object , List1 , ResolutionContext ) --- End of inner exception stack trace --- at lambda_method117(Closure , Object , List`1 , ResolutionContext ) at FilmesApi.Controllers.CinemaController.RecuperaCinemas() in C:\Users\bisma\source\repos\FilmesApi\FilmesApi\Controllers\CinemaController.cs:line 36 at lambda_method113(Closure , Object , Object[] ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

HEADERS

Accept: / Connection: keep-alive Host: localhost:7221 User-Agent: PostmanRuntime/7.34.0 Accept-Encoding: gzip, deflate, br Postman-Token: ecaaeff5-6079-4481-9e05-1d834c367517

1 resposta
solução!

Oi Bismark, tudo bem?

Pelo erro que você está recebendo, parece que há um problema de mapeamento entre as entidades Cinema e ReadCinemaDto. O AutoMapper está tentando mapear esses tipos, mas não está encontrando uma configuração adequada.

Uma possível causa desse problema é que o mapeamento entre as entidades não foi configurado corretamente. Certifique-se de que você possui uma configuração de mapeamento adequada entre as propriedades das entidades Cinema e ReadCinemaDto. Por exemplo, se a propriedade Endereco da entidade Cinema precisa ser mapeada para a propriedade ReadEnderecoDto da entidade ReadCinemaDto, você precisa configurar esse mapeamento no AutoMapper.

Aqui está um exemplo de como você pode configurar o mapeamento entre as entidades:

CreateMap<Cinema, ReadCinemaDto>()
    .ForMember(dest => dest.Endereco, opt => opt.MapFrom(src => src.Endereco));

Certifique-se de que você está configurando todos os mapeamentos necessários entre as entidades. Se você estiver usando o AutoMapper em outros lugares do seu projeto, verifique se todas as configurações de mapeamento estão corretas.

Além disso, verifique se todas as dependências necessárias estão sendo injetadas corretamente no seu controlador CinemaController. Se alguma dependência estiver faltando, isso também pode causar o erro de mapeamento.

Um abraço e bons estudos.

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software