From the course: Advanced ASP.NET Web API 2.2

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Resolving dependencies with Unity

Resolving dependencies with Unity

From the course: Advanced ASP.NET Web API 2.2

Start my 1-month free trial

Resolving dependencies with Unity

- [Instructor] When building apps and when using services to access the data that we want to process, we need to make sure that our dependencies are resolved. And to do so, we can either create our own containers or we can use the existing IoC containers. An IoC, or inversion of control container, which is responsible for managing our dependencies. And some of them are Unity, Autofac, Ninject, StructureMap, Spring.NET, etc. For this course, we are going to use Unity. But why do we need to resolve the dependencies in the first place? For that, let us go to Visual Studio. In here we have a model inside the models class. Then we have an interface IStudentRepository where we define two methods, GetAll and GetStudentById. Then we have the implementation of this repository in here. In here, you can see that we have hard coded the data but normally you'll be getting the data from a database. If we go to the StudentsController, in…

Contents