I'm studying domain-driven design and building a solution (using C#, .NET 8) with 4 layers: Presentation, Application, Domain and Infrastructure. I have some questions about how to proceed with the implementation:
I saw in some examples the application, domain and infrastructure interfaces all concentrating in domain layer. But, when I building the my projects, I was wondering if is more organize to put an interface in your respective layer. Example: UserApplicationService
has IUserApplicationService
. Can I put the IUserApplicationService
in Application layer or does it have to be in Domain layer?
I'm using Dapper to get the data from SQL Server in Infrastructure layer, through the repositories. I have to get all active users, so, in my UserRepo
has: select * from user where active = 1
. But, get the active users is a business rule. So I have 2 options: maintain the select with where clause or get all users and filter them in domain layer. If I choose the first option, I not following the principles of DDD? (because the rule of get active users is in infrastructure layer). But if I choose the second option, and if I have 1.000.000 clients, I will lose performance. How to proceed in this case? What is the best solution for this example?
I have a worker service project. He has to be in Presentation Layer because is a Startup project or in Application layer because doesn't have input of users and just manipulating data received by the domain layer services?