I want to build a web application with 3-tier architecture in ASP.NET. But I am getting a problem of circular referencing.
I have 3 layer:
- Application layer containing UI.
- Business layer containing all the logic and domain classes.
- Data layer containing all database interaction methods.
I am using the data layer methods in business layer to perform database operations and in these methods I need to pass domain class object to data layer but it can not be done due to circular referencing.
For example I have a Person
domain class containing some properties and methods. Now I want to insert that Person
into database. I have a method in Person class, named as InsertPerson()
. In this method body, I have to call the function of Data layer to insert into database. But I am not able to pass the whole person object into data layer method as data layer reference is added to business layer and vice-versa is not possible.
So how can I avoid this problem? Please suggest.