0

I have database context which takes parameter. I would like to depend this on request parameter. Is there any possibility to do that?

  • Is there some reason why the [How do I pick a service implementation by context?](http://autofaccn.readthedocs.io/en/latest/faq/select-by-context.html) documentation wasn't helpful? To do this sort of thing so it is portable across DI containers, see [Dependency injection type-selection](https://stackoverflow.com/a/34331154/181087). – NightOwl888 Mar 20 '18 at 06:50
  • Possible duplicate of [How do I resolve a WebAPI dependency in Autofac that requires a parameter from the route?](https://stackoverflow.com/questions/49241204/how-do-i-resolve-a-webapi-dependency-in-autofac-that-requires-a-parameter-from-t) – Travis Illig Mar 20 '18 at 12:16

1 Answers1

0

You might want to check out the keyed services feature in autofac. With keyed services, you can map different objects to a specific key or name.

Can't tell if that's exactly what you need without knowing the context. Can you please provide a pseudo code as to what you are trying to achieve?

ragyaiddo
  • 152
  • 1
  • 4