Does Dependency Injection violate the Separation of Concerns as it pertains to an n-tier architecture?
Suppose you have the following projects:
MyApp.Data
MyApp.Business
MyApp.Web
If I were to use DI to tell the Business Layer which Data Context to use, wouldn't this violate SoC? This would mean the UI (MyApp.Web) would have to have knowledge of the Data Access Layer (MyApp.Data) to tell the Business Layer (MyApp.Business) which context to use, right?
public class WebForm {
public void Save(Object dto) {
BusinessObject bo = new BusinessObject(Data.MyDataContext);
bo.ValidateAndSave(dto);
}
}
I always thought, in an n-tier architecture, each tier should only have knowledge of the next tier (UI to Business, Business to Data). Is this not really a big deal?