Build a three-layer. Net Core MVC + three-tier process that is puzzling and wants to refine the project

Source: Internet
Author: User

After learning the basics of. Net Core MVC, I wanted to write a demo, but in the process encountered a lot of problems, my memory is poor, listened to the comments, records, to solve the problem.

Because companies are using the previous technology, there is no stratification of this statement, I came out of the school soon, I always want to simple layering to use the. Net Core MVC + three layer to do a demo,

In actual development there are some basic projects that need to be used, such as logs, exceptions, filters, dependency injection, etc. i want to learn this part because of the basic use of the project later on.

In the process of building the three-layer. Net Core MVC + three layer, there has been a lot of confusion, understanding how to write a layer, sometimes think for a long time, or write after the online post, and then modify the code. Feeling has been very confused.

Here is my build of the. Net Core MVC + three-tier project, which has a lot of shortcomings I hope someone can help me see Kazakhstan, need to modify, optimize the place thank you!

1, the structure of the project: here to thank the blog to provide the source of predecessors to let us learn, thank you

Projectcore.common: It's a public class and method.

Projectcore.entity: Entity class

ProjectCore.Repository.Contract: Data Access Layer Interface

ProjectCore.Repository.EF: Concrete implementation of data access layer

ProjectCore.Service.Contract: Business Logic Layer Interface

Projectcore.service: The specific implementation of the business logic layer

Here is the interface of the data access layer

Here is the interface specifically implemented by the data access layer

here is code after the data access layer inherits:

1, the beginning even here can not understand his meaning, so I went to consolidate the basic knowledge, interface inheritance, implementation interface, class inheritance

Note: In the Idemorepository interface inherits the Ibaserepository,idemorepository therefore he has the ibaserepository inside the attribute , The Baserepository class implements Ibaserepository so Demorepository has all of their properties

Here is the interface of the business logic layer

here is the concrete implementation of the business logic layer

Then the controller's code

1, the storage mode is applied in the data access layer, and the data access layer applies the iservicecollection extension to implement the dependency injection and the business logic layer with AUTOFAC dependency injection.

iservicecollection Extension implements Dependency injection: Enables the data access layer to implement dependency injection in a generic manner

AUTOFAC the benefits of Dependency Injection : It started with the AUTOFAC dependency injection But Idid not find a solution to the data access layer when it was implemented in a generic manner. AUTOFAC

They can implement the dependency injection of the assembly, so as not to create a lot of classes later without a single write-dependent injection, mainly not found in. NET core MVC with the assembly dependency Injection method

these are by looking at the post and download the source code, there are now in the maintenance of a project source code to learn some of the knowledge

One of my questions: it's built like this. Net core MVC + three layer is reasonable, need to optimize or need to modify the place please guide thank you

My question two: I want to verify the accuracy of the data in the background using fluentvalidation validation, thefluentvalidation Validation class should be placed on that level

Construction . NET core MVC + three is it reasonable that the question is reasonable I changed it many times

1, in the data access layer I did not use generics but write well found that many places are repeated use of, query, modify, delete and other methods so see the post using the warehouse

2, for now this way, the use will increase the workload, but I understand the construction project in order to make it easier to maintain, development efficiency, because I now, deeply affected by their own code written by the maintenance of the time, the change is a bit large.

3, the company although there are some technical good predecessors and colleagues, but they are fast development as the goal of development, how fast how to develop, repeated code a lot, if I do not study now, the back will be very miserable.

4, the company gave me a few things, basically is to let me maintain a project, good to the project of the 2 phase development, the company there is no one basically nobody will this knowledge, all feel I learn. NET core + is a wrong decision, so I would like to consult the predecessors, and colleagues in this respect, Improve your own technology

The first time to write a blog: unknowingly written nearly 1 hours, may be a little nervous, you can imagine those who often send a post to help us solve the problem of the author, in the back of the pay, like they salute! Hope to help me answer the question Thank you!

Build a three-layer. Net Core MVC + three-tier process that is puzzling and wants to refine the project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.