For that to work you need to use Dependency Injection (DI). If you google "web api dependency injection" you'll find lots of examples, it might help if you know the DI framework you want to use in advance (Castle Windsor, Autofac, Ninject, Unity etc), however her is the MS docs which uses Unity
Dependency Injection in ASP.NET Web API 2 | Microsoft Docs[
^]