Timeline for Dependency Injection With Unity in MVC 5 without repository and unit of work
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 20, 2015 at 4:30 | vote | accept | koushik | ||
Jan 19, 2015 at 19:26 | comment | added | ChrisWue | @user3132179 If you inject an interface then you should only use what the interface provides. If that is not enough and your controller depends on a concrete implementation then it should be getting the concrete implementation injected or the interface needs to be expanded. There absolutely no point to inject an interface and then cast it to a concrete implementation - this defeats the whole purpose of injecting the interface. | |
Jan 19, 2015 at 12:42 | comment | added | koushik |
i just don't want to use new operator to create objects. also i want to have my db calls in the controller itself. I dont know if my approach is right.
|
|
Jan 19, 2015 at 12:36 | comment | added | Heslacher | Then, why do you inject the interface instead of simply passing the concrete implementation ? | |
Jan 19, 2015 at 12:33 | comment | added | koushik |
if i don't cast the interface object of DbContext then how will i do the SaveChanges() . cause the interface does not contains the SaveChanges() ? I don't want to new-ing objects in my controller.
|
|
Jan 19, 2015 at 12:21 | history | answered | Heslacher | CC BY-SA 3.0 |