Build a backend management system for ASP. Mvc5+ef6+easyui 1.4.3+unity4.x Injection (61)-How do I use frameworks for development?

Source: Internet
Author: User
Tags spl

Objective:

Some of my friends often ask how to develop correctly and quickly, but I tell you that there is nothing more to help a document than to do it yourself, no code generator

This section is dedicated to taking some time to demonstrate the data flow of this framework in very, very detailed, and no nonsense to say, start now! Look at a picture below to see how the data to the front end is fully understood!

Just look at the Red section, which is a typical three-layer pattern. In fact, this picture is just a review of our past! The DAL gets the database data, which is handed to the business layer to process the logic after the delivery controller is serialized to the front

From user request (View)--Controller---Business process (BLL)--(data access) dal--finally get the data

-------------------------------------------------------------------------Ugly Split-line------------------------------------------ ----------------------------------

Directory

The above is just a beginning, let's go to the topic quickly! Roughly divided into the following 5 steps to complete:(in fact, a pure look at hand speed, fast hand speed of 5 minutes can be run)

——————————————————————————

    1. Conventions
    2. Building class libraries and regions
    3. Mutual references
    4. Code generation
    5. Run

——————————————————————————

1. Conventions

In fact, when I finished writing permissions, I found a lot of repetitive coding things, so casually wrote a code generator, each time using the code generator found that the code generator generated code many are the same, so the use of T4 refactoring the repeating part.

This is in the actual process to explore the process of perfection, no architect, a Emerson project at the outset to put forward the best structure, only the continuous reconstruction of the perfect, finally to reduce the maintenance cost of the framework!

If we are a large-scale application system, which contains many business modules, such as financial management, human resources, sales, production, workflow, then I am such a division, but also a convention

A good system they can be split and combined, so I sub-module, a submodule contains bll,dal,ibll,idal you can also sub-folder, that is the same

Sample (SPL) is demonstrated in a sample module, so we must have the following conventions:

database table prefix: Spl_

Class Library Name: Apps.Spl.XXX

Controller area: SPL

Models folder: SPL

(Although not mandatory, this is also the code specification)

2. Creating a class library and region

Copy all T4 from Apps.base to apps.spl corresponding BLL,DAL,IDAL,IBLL layer, respectively

and modify the T4 content of the usingname prefix to SPL. (prefix for the contract of the data table)

Class Library: (You don't need to do this if your project is categorized as a folder rather than a class library)

Regional:

and modify the routing rules as follows (multi-language regular expressions)

View Code 3. Class Library References

(If your project is categorized as a folder rather than a class library, you do not need to do this step)

in order to reference the class library, we first set up two tables, only the table has T4 to generate, will be generated error, after the error to help us to the Library reference , OK

I created two tables here: Table data from SQL2012 's sample database AdventureWorks2012 you can find through Baidu

Table structure I was built by myself, relatively simple, you can casually build your watch!

the statement that extracts the data (see if you are interested)build a table statement (see if you're interested)

This is a table of product-to-category relationships! Nothing.

According to the error message we will refer to the class library separately, the class library needs to reference the relationship as shown in

Only look at the red box can, white for the system of the original class library, although it seems to be very complex, hand speed is actually a minute thing just!

Don't forget to inject. The Unitydependencyresolver class library under the App.core

4. Code Generation

Create a new 2 controller. Productcontroller and Productcategorycontroller

Finally go to the finishing touches, and the next thing is generated by the code generator! After generating the code, copy it into the controller and view to

5. Running

Run the system, and finally set up the permissions and modules.

Finally, refresh the system. of the leverage

Summarize

The article is very long, but in detail, after reading the frame recognition increased by at least 200%.

Main steps to complete. New Class Library----> Database tables----> Generate code----> run directly. The speed is actually only 5 minutes, no difficulty to speak

Almost no line of code to achieve the display of the interface, if the code generator to optimize will be able to support multi-table joint query, support composite real development business, then the speed of coding is a qualitative improvement

Thank you.

The next section shows you how to add features other than builds! How to use code to do other things

Build a backend management system for ASP. Mvc5+ef6+easyui 1.4.3+unity4.x Injection (61)-How do I use frameworks for development?

Related Article

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.