In my view, what you are trying to achieve is good way to architect the project. I am also doing same; just small difference that I will explain below. Not referencing DAL in API makes sure that every call to DAL is only through BLL. This is necessary because I want to put my all data processing logic at one place. If it is distributed, it is hard to locate issues.
I have four projects:
- Utils (your "blabla" stuff goes here) [References nothing]
- DAL (your database stuff goes here) [References Utils]
- BLL (your logic stuff goes here) [References DAL and Utils if needed]
- Api (your API stuff goes here) [References BLL and Utils if needed]
This is one way reference chain. DAL => BLL => API
. References in reverse order should not exist. Utils
should be common stuff where common things like Entity declarations, Exceptions, Enums should go.
Note: Eventhough you are not referencing the DAL in API, you have to deploy it.
To avoid using Utils
in API, you may need to add one more layer of DTOs and map them with Entities. Refer my other question on same.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…