This is the ApiController I want to use to get this Data.
[Route("api/[controller]")]
[ApiController]
public class TestController : ControllerBase
{
private readonly IRegionService _service;
public TestController(IRegionService service)
{
_service = service;
}
[HttpGet]
public IEnumerable<RegionModel> Get()
{
return _service.GetAll();
}
[HttpGet, Route("api/region/getAll")]
public IEnumerable<RegionModel> GetAll()
{
return _service.GetAll();
}
}
Now To get this data, I go through the steps explained in the title.
IService->Service->IRepository->Repository
From Respository I get the data using LLBLGen.
How do I put scope to use this repository in the project? I am also using AutoMapper and created Automapper.cs.
I added to the Automapper.cs as below
CreateMap<IRegionService, RegionService>();
CreateMap<IRegionRepository, RegionRepository>();
and getthing this error.
Unable to resolve service for type ' .Services.IRegionService' while attempting to activate ' .ApiController.TestController'.
AutoMapper is a tool for Mapping, not for DI.
You must register
IRegionServiceandIRegionRepositoryintoDIin startup class like this