I have some problem with my application. Recently I've downloaded Ninject packages and I cannot bind my entities.
My controller:
public class ServerController : ApiController
{
private readonly IServerService _service;
public ServerController(IServerService service)
{
this._service = service;
}
RegisterServices:
private static void RegisterServices(IKernel kernel)
{
kernel.Bind<IServerService>().To<ServerService>().InSingletonScope();
kernel.Bind<IRepository<Server>>()
.To(typeof(ServerRepository))
.InRequestScope();
}
ServerService:
private readonly IRepository<Server> _repository;
public ServerService(IRepository<Server> repository)
{
this._repository = repository;
}
public async Task<IEnumerable<Server>> GetAllAsync()
{
return await this._repository.GetAllAsync();
}
If someone needs more info I'll send it to comments.
The problem has been solved. I just added new interfaces to DAL model and implemented IRepository. After that my Ninject register looks like:
kernel.Bind<IServerService>().To<ServerService>().InSingletonScope();
kernel.Bind<IServerRepository>().To<ServerRepository>().InSingletonScope();