title: Tight coupling of Application and Infrastructure projects
body: <p>In my Infrastructure layer I have created a project for an Azure Search Query service, which implements (my own) ISearchQueryService interface.</p>
  
  <p>Also in the project is an Index Model, which is marked-up with various Azure Search specific attributes.</p>
  
  <p>Both depend on the Azure Search SDK.</p>
  
  <p>In the project I’ve also added a model for an Azure Search Configuration (read from appsettings.json)  and injected into the service constructor. This has Azure-Search-specific property values, such as Azure service keys.</p>
  
  <p>An ISearchService method, implemented by my service, allows the index to be searched using a class in the Azure Search SDK. The latter takes parameters such an ODATA filter expression with fieldname/values and a list of fieldnames for ordering.</p>
  
  <p>I call ISearchQueryService methods from a Controller Service in my Application layer.</p>
  
  <p>I want to keep the ISearchQueryService methods as generic as possible so I could pass in the parameter values to the service, something like:</p>
  
  <pre><code>var departurePointSearchQueryDto = new DeparturePointSearchQueryDto
  {
                  Filter = $"{nameof(IndexedDeparturePoint.TransitType)} eq 0",
                  OrderByFieldNames = new List&lt;string&gt;() { $"{nameof(IndexedDeparturePoint.DeparturePointName)}" }
  };
  </code></pre>
  
  <p><strong>I use "nameof" to get compile-time checking of the index field names but this means my Controller Service now directly references the Azure Search Query project.</strong> </p>
  
  <p>I’m not sure if this is an issue as the Index model, Configuration model and the ISearchQueryService method signatures are highly specific to Azure Search. Switching to another search provider would mean they would all need to be rewritten anyway – there’s no easy way to swap one implementation for another.</p>
  
  <p><strong>Q. On that basis is the tight coupling reasonable? If not, what should I consider?</strong></p>