Multi Layer .Net 6 App

ANB 181 Reputation points
2022-02-23T15:59:07.12+00:00

I've been debating with a friend, what'd be the best practices for project layers.

I've chosen:

  • UI
  • API
  • Services
  • Dal
  • Models

He's chosen:

  • UI
  • API
  • DAL

In his opinion I could have the logic on the API controllers and access DAL directly.
He would also have DTO models inside DAL and cascade down objects to API layer.

So what'd be the best approach ?
I understand that keeping the controller clean just calling the services would be better for organization, and also if I want to plug a desktop application to the solution later, but for something else ?
Also having the Models in a project apart, wouldn't be better ?

Please give me your thoughts.
Thx

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,502 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 63,746 Reputation points
    2022-02-23T16:22:51.61+00:00

    neither seems enough layers for an enterprise project.

    just for the DAL I'd have at least 3 projects (layers)

    DAL-API - dal model and interfaces
    DAL-Rules - dal internal rules and logic
    DAL-Database - actual database calls

    you want to abstract each layer as much as possible, and use adapters for communication between layers.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.