How to use ninject in mvc multiproject application?

My application is configured this way. Web Data Services POCO Objects

Controllers use services (therefore they should be introduced) Services use repositories (which, I believe, should also be introduced)

I have already configured so that the controllers get the right service through Ninject, but I'm not sure how to do this using services => repositories

any help with this?

+3
source share
3 answers

ninject.web.mvc. , , Global.asax.

+1

, . Ninject .

, ProductController IProductService IProductService ProductService, IProductRepository IProductRepository NHibernateProductRepository, ISession.

when your NinjectControllerFactorytrying to resolve ProductController, he sees a dependency on IProductService. he solves this dependence as ProductServicehe sees that it has a dependence on IProductRepository. and he will continue to move down the chain until he can fully resolve the dispute.

therefore, an important part is the binding of ANY dependencies, and not just to the controller.

-1
source

Source: https://habr.com/ru/post/1790368/


All Articles