Write your own C # framework (11) from scratch-create a solution

Source: Internet
Author: User

During this period of time, I have been charging and reading the blog of the gods in the Garden (wayfarer's design path and TerryLee's 《. NET Design Pattern series articles, and kanodamo's design pattern series also have some other scattered articles), which have benefited a lot. Although it is still a bit confusing for most of the design patterns, it is still very knowledgeable. In addition, I also bought the masterpiece "big talk reconstruction" of Fan gang in the garden and "refactoring: improving the design of existing code" recommended by other great gods. I read a book one hour early every morning, I feel that this time is clear and the reading efficiency is extremely high. I suggest you read these books carefully. If you have time, you should watch and practice them repeatedly.

According to the development plan, on the 5th, we started to enter the code writing stage and began to write the Framework Code. At the same time, we have been thinking about how to easily clarify the entire code writing process and relevant details? The compilation of the Code explanation is not clear in three or two sentences. You can use the video to understand it, but you have no experience and don't know how to do it. So after careful consideration, I feel that, if the implemented code is sent out at one time, too much content is not convenient for everyone to understand some details, or write the code development methods in sequence according to the code implementation steps, features are not implemented at one time. When you need to use related functions, You Can refactor the class or code to add features. You can also understand the development process and ideas.

After the final implementation of this architecture, code integration will be relatively high, but the problem is not very big for small and medium-sized projects, because most code is directly generated using the T4 template, you only need to modify the changes in the template function.

Template functions are implemented for the purpose of reducing the development workload. for independent functions, You need to develop custom functions for implementation. These functions are described in detail in the following sections.

The copyright of the previously developed project code belongs to the company, so this project will use some open source code on the Internet, and some related function functions will be rewritten.

In addition, although a development plan has been developed, encoding and article writing are certainly not synchronized, so sometimes the article will be published later, please forgive me.

 

The code will not be repeated.

 

1. First, create a blank solution and add four Solution Folders (mainly for the sake of clear classification and storage after the project is added, if the project contains services, Winform, and test items, you can create more folders)

  

 

2. Go to the sufeinet network and download the C # base class library shared by Su Fei. I am very grateful to Su Fei for sharing so many excellent tool classes with many netizens.

  

  

3. Place the C # base class library, SubSonic3.0 plug-in project, DAL Layer Code, and common DLL files in the newly created solution folder.

  

 

4. Add the C # base class library and SubSonic3.0 plug-in project to the Common folder, and add Solution. DataAccess to the DataAccess folder.

  

 

5. Change the DotNet. Utilities project attribute to. NET Framework 4.

  

 

6. Add Newtonsoft. Json. dll references to DotNet. Utilities, add Castle. Core. dll references to SubSonic. Core, and add DotNet. Utilities and SubSonic. Core Project references to Solution. DataAccess.

  

  

  

 

7. Create a database

According to the introduction in Chapter C # framework (9)-database design and creation from scratch, use the tool "ExcelToSQLString2.91 _ SQL" and "Data Dictionary" attached to the chapter to generate a database.

Create a database SolutionDataBase

  

  

Download Attachment data library design and creation chapter attachment .rar and decompress

  

Open Data Dictionary and copy the data table name

  

Open exceltosqlstring2.91_ SQL .exe, design the file path, paste the copied data table name out of the table name, tick and select by chart, and click Run to generate an SQL statement

  

  

Open the database, select the SolutionDataBase database, click Create query, copy the SQL statement generated above to the query analyzer, and then click Execute

  

Repeat the preceding action to create all the tables in the data dictionary.

  

Add a database management account

  

Create login name SolutionUid, password 123456

  

Select Permissions

  

 

8. Modify database links

Open Solution

  

Modify the database connection string to the login name and password of the database created earlier.

  

Modify T4 template Database Name

  

 

9. Operate the T4 template to generate the DAL layer File

  

  

Check the App if the following error message is prompted during the generation process. check whether the login name and password in the config database connection string are correct. If they are correct, click Save App. config configuration file, because the T4 file sometimes produces errors because the configuration file cannot be obtained. Generally, it can run correctly after being saved.

In addition, you may also check the database name and use an nonstandard name or a keyword to name the database name or table name.

  

  

 

For more information about the functions of the files at different layers of the framework, see the descriptions of directories and files in the "Data Dictionary" in the attachment.

  

 

The next chapter will be published on Wednesday or Thursday. It will mainly explain the application of the logic layer T4 template (the use of the T4 template is the core of this framework)

 

 

 

: Http://yunpan.cn/QirUs45ckaPCT access password e110

 

 

Copyright:

This article was originally published by AllEmpty and published in the blog Park. You are welcome to repost it. You must keep this statement without your consent and provide the original article link clearly on the article page,Otherwise, the right to pursue legal liability is reserved.. If you have any questions, you can use1654937@qq.comThank you very much for contacting me.

As long as you are interested in learning and making progress together, you can add Q group: 327360708 to this topic.

For more information, please refer to blog: http://www.cnblogs.com/EmptyFS/

 

 

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.