SubSonic3.0 uses Demo1.0 -- The Application of the T4 template can reduce the code volume by more than 70% during development and the error rate by more than 80%.

Source: Internet
Author: User

At the request of netizens, I took some time to write this Demo. I hope it will be helpful for friends who want to upgrade version 2.2 to version 3.0 or who are using version 3.0. If you find any problems or suggestions during the Demo process, you can directly submit the Bug to me or tell me that I will take the time to handle it. If you support my articles, please log on to my blog and recommend that you have your support. I will be more motivated.

This Demo uses the T4 template to achieve rapid development through the template application. In my actual project, this reduces the amount of code by more than 70% (computing code is placed on the logic layer, and most of the logic-Layer Code is directly generated) and more than 80% error rate (the most common error for programmers is the visual fatigue generated after the mechanical copy and paste operation, because no relevant name after the copy is modified)

 

========================================================== ======================================

Name: SubSonic3.0 use Demo
Version 1.0
Last Updated: 2013-9-13

Author: Empty (AllEmpty)
Email: 1654937@qq.com
Learning discussion: SubSonic3.0 Learning Group (327360708)
Blog: http://www.cnblogs.com/EmptyFS/

========================================================== ======================================

 

Development Environment:
Vs2010 + SubSonic3.0.0.4.2 + ExtAspNet3.1.9.2


This Demo simply implements login, Administrator Table query, and addition, deletion, modification, and status change of Administrator records.
Use the SubSonic3.0.0.4.2 plug-in + T4 template to generate the underlying layer
The logic layer uses the T4 template to generate various call functions required during the development process. In actual projects, the framework developed in this mode reduces the code development workload by more than 70%, the error rate will also be minimized. Programmers only need to simply copy and paste them, and then modify some UIS to develop functions of the website background management system or enterprise management software, you only need to implement some logic processing in a small part of the page that requires some logic processing, which greatly reduces the workload of project development and improves the development efficiency.

This Demo only implements simple functions and does not detail the various functions of the Management System. It only provides a fast development idea through this Demo, after in-depth research, you can give full play to your imagination and needs.

For more information about directories and files in the Demo, see the data dictionary in the attachment.

Text. aspx. the cs file is a variety of Use Cases of SubSonic3.0. If you are not familiar with SubSonic3.0, you can set it as a startup Item, start the DeBug debugging method, and view the debugging line by line to know how to use it, it contains various commonly used call methods for plug-ins.

In addition, it should be noted that DataAccess/SubSonic/EntityTable. entityTable generated by tt. cs file, which directly generates the data table name and related field names. You can directly use DataAccess. dataModel. T + Table (such as ManagerTable. tableName can be used to obtain the table name ...) obtain the data table name and each field name. This method can reduce the hard encoding in the Code, so that VS will directly report an error when modifying the database field or content, so that we can immediately know where to modify to reduce the possibility of errors.

The SubSonic/CreateBll. tt templates in the Login project are mainly used to generate various logical classes #
Foreach (var col in tbl. Columns ){
If (col. Sort ype = "byte ")
{
#>
And
<#
}
}
#>
# Endregion template generation function

Different methods are generated based on different field names.

 

The generated logical class content,

 

During implementation and use, you can define different field names to screen the program and generate the functions you need. This will greatly reduce the development workload and use the generation function, it can avoid the visual fatigue caused by mechanical copy and paste during development, and the error caused by not modifying the relevant name. Because the generated logical class uses the partial class modifier, we can also define a logical class with the same name, which contains methods that cannot be generated using templates, in this way, the generation and user-defined methods are separated to process two files, so it takes a lot of time to copy, paste, and modify the related classes after modification.

It should be pointed out that the SubSonic3.0 plug-in currently does not support the nested brackets function. When there are double brackets, it will be interpreted as multiple single brackets or even errors, so pay attention to this when you add query conditions. Wait for time to study the code and check whether the nested brackets function can be added. When In queries are used, the plug-In cannot be well explained, So I encapsulated ConditionHelper. cs condition class, which converts In queries into query statements with multiple Or relationships equal to the same. It is also worth noting. For details, refer to Test. aspx. example in cs.

 

: Http://yunpan.cn/QGFA6U8p8cz4M

Updated at on, and modified a small Bug in the query condition encapsulation class (SqlqueryCondition. cs ).

 

This article is original content. Keep the following information for reprinting.

As long as you want to learn and make progress together, if you are interested, you can add the Q group: SubSonic3.0 Learning Group (327360708) or Email to me (1654937 # qq.com ), I am very busy. If you have any questions, please leave a message first. Please forgive me for not replying in time.

For more questions about SubSonic3.0, refer to the blog:

 

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.