views:

183

answers:

1

If you have a system that has multiple types of object contexts. For Eg: BillingObjectContext, HumanResourceObjectContext etc. All derive from ObjectContext but ObjectContext Class does not implement any specific interface like IObjectContext. How would you apply DI/IoC in case of multiple types of ObjectContext say using Ninject?

+1  A: 

If you must depend on it in a test, you have to mock it. Here's a sample; it's not much harder than implementing an interface. See also TDD improvements in EF 4.

Craig Stuntz
+1 for the stuff about mocking it out but what about Injecting appropriate ObjectContexts where needed ?
Perpetualcoder
That's what DI/IoC is for. Make your repository take the context as a constructor argument.
Craig Stuntz