@embiid

Как заинджекать сервис ASP.NET Web Api?

Как заинджекать мне для сервиса интерфейс?

Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: X.Services.Interfaces.ServiceInterfaces.IWishListItemService Lifetime: Scoped ImplementationType: X.Infrastructure.Business.Services.WishListItemService': Unable to resolve service for type 'X.Domain.Interfaces.EFInterfaces.IWishListItemRepository' while attempting to activate 'X.Infrastructure.Business.Services.WishListItemService'.) (Error while validating the service descriptor 'ServiceType: X.Services.Interfaces.ServiceInterfaces.IWishListItemService Lifetime: Scoped ImplementationType: X.Infrastructure.Business.Services.WishListItemService': Unable to resolve service for type 'X.Domain.Interfaces.EFInterfaces.IWishListItemRepository' while attempting to activate 'X.Infrastructure.Business.Services.WishListItemService'.)


Сервис:
public class WishListItemService : IWishListItemService
    {
        private readonly IMapper _mapper;
        private readonly IUnitOfWork _unitOfWork;
        private readonly IWishListItemRepository _wishListItemRepository;
        private readonly IProductDetailsRepository _productDetailsRepository;

        public WishListItemService(IMapper mapper, IUnitOfWork unitOfWork,
            IWishListItemRepository wishListItemService, IProductDetailsRepository productDetailsRepository)
        {
            _wishListItemRepository = wishListItemService;
            _productDetailsRepository = productDetailsRepository;
            _unitOfWork = unitOfWork;
            _mapper = mapper;
        }


Кoнтроллер:
public class WishListItemController : ControllerBase
    {
        private readonly IMapper _mapper;
        private readonly IWishListItemService _wishListItemService;

        public WishListItemController(IWishListItemService wishListItemService, IMapper mapper)
        {
            _mapper = mapper;
            _wishListItemService = wishListItemService;
        }
  • Вопрос задан
  • 317 просмотров
Пригласить эксперта
Ответы на вопрос 1
vabka
@vabka Куратор тега ASP.NET
Токсичный шарпист
Зарегистрируй, как и WishListItemService.
Скорее всего где-то в Startup.ConfigureServices
services.AddScoped<IWishListItemRepository, WishListItemRepository>()
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы