I'm creating my first web application with ASP.NET MVC 5 and want to do it the right way. I plan on creating an architecture with a Presentation Layer (MVC), a Data Access Layer (DAL), and a Business Logic Layer (BLL). The DAL and BLL will be separate class libraries from the MVC project. The idea is that the MVC project will reference the BLL to perform business logic which will then reference the DAL for interacting with the database. I am employing the repository pattern.
My question is, how is data passed between layers? For example, let's say I have an Entity Framework model in the MVC project for a Student class with properties FirstName and LastName. Then I create a strongly typed view where the user can add a student by filling out a simple form and clicking 'Save'. The Student model will be posted to the corresponding action method in the Controller, correct? Then wouldn't the Controller need to send the Student object to the BLL and from there to the DAL to be inserted into the database? But how can that be when the BLL and DAL don't know anything about the Student class?
I don't understand how this can work without creating a circular dependency. Can someone please explain or provide code examples?
Thank you in advance.
Aucun commentaire:
Enregistrer un commentaire