I am working on MVC project where I am following the layered architecture. After reading and researching on the web, I figured out that having seperate layers is optimal approach. So, my layers are:
- Presentation layer has: Controllers, Views
- Business Layer: Separate class library project (Includes domain models(Representing table entities), business logic services, separate folder for ViewModels)
- Data Access Layer: Has calls to the database (SQL statements, connections)
Now, the problem arises :
BLL calls to Data access layer :
public PartnerOperation(IDataAccess dataRepository)
{
_dataAccess = dataRepository;
}
public void InsertRequest(PartnerRequestModel partnerRequestModel)
{
_dataAccess.InsertIntoDB(partnerRequestModel); //Domain object passed to DLL method
}
Now, my BLL is depending on Data access layer which is depending on BLL because domain objects are inside BLL. So, both are having reference to each other.
I am rigorously searching on it for couple of weeks, but couldn't find a way out.
I have already gone through Business Logic Layer and Data Access layer: circular dependency but it doesn't address my problem completely.
Some websites support layer architecture, some claimed Onion Approach is better. For instance: this article claims that this whole approach (Controller -> BLL ->DLL) is not optimal.
- How can I overcome the circular dependency?
- Is my approach toward building this Web Application valid?