Reputation: 16060
I am learning asp.net mvc and I am building an application that has to serve multiple clients.
Now in a typical asp.net mvc we usually have a composition root class (bootstrapper) where we do all our dependency injection(Unity in my case)
now suppose we are really talking to a wcf service how do you inject the repository?
I dont see a way to inject myRepository interface in my bootstrapper!Am I missing the obvious?
The only way of doing this is by creating the repository in my business layer.
Given the above is it possible to inject the repository into the service?
When Unittesting I will we be mocking(moq)the repository injecting into the businessLayer.
any suggestions?
thanks for your time
Upvotes: 4
Views: 625
Reputation: 5800
The solution we came up with which I don't like is to call DependencyInjection.Resolve<IBusinessLogic>() in each call on the webservice. I would definitely prefer some sort of boot-strapper to do some constructor injection into the implementer of the WCF interface. We just didn't have enough time to dig deeper into WCF.
Anyways, this link would be a great place to start down this path.
Upvotes: 1