Difference between SQL code generated by soft Codematic and NHibernate code generated by CodeSmith

Source: Internet
Author: User

The most obvious comparison is that the three layers of dynamic Software Generation are based on databases, while CodeSmith is based on nhib.pdf

 

 

1. Dynamic Soft Layer-3 Architecture

When developing an ASP. Net application, it is suitable for beginners to use a three-tier architecture automatically generated by dynamic software. All annotations are in Chinese and easy to use. It is difficult to change. For example, to add a method to query data, first add an interface method to the DAL layer, then add the implementation code to the SQLServerDAL layer, and then add a packaging method to The BLL layer. If you add a field to a table, you have to refresh it again. Otherwise, you have to change it one by one.

The IDAL layer can be implemented by OracleDAL or DB2DAL to shield details of data operations. The BLL layer is necessary to encapsulate the business processing logic. The data access layer and business logic layer are displayed. The presentation layer is the aspx page. You can call BLL to obtain the data and then present it to the user. In many cases, the data is displayed in the GridView.

During Development, The BLL layer has two features: processing business logic and displaying data, which can be separated. The software generates a BLL-layer class for each table in the database, and some tables do not correspond to specific business logic (such as company information table and personal information table ), some tables need to be mixed with other tables to complete the business logic (for example, to process the Admin table for website login, You need to combine the user table and role table ). This can be improved. For classes that only provide data and do not process business logic (such as user tables), they are managed by a class and a table name (which is encapsulated by a view) and the query condition, the class returns the corresponding data, which is easy to implement. Abstract The business logic class.

 

2. Three-layer structure of nhib.pdf

As an object relationship ing framework, nhib operates databases in an object-oriented manner, which is simple and convenient. The "three-tier structure of nhib.pdf" used in the project is as follows ":

Supported by nhib.pdf, the entity classes of each Model layer can encapsulate data operation methods (such as Save and Update), and The BLL layer can be conveniently called. In fact, BLL mostly involves operations on a single object (ADD, update, and delete). This nhib.pdf is strong and can be well implemented in an object-oriented way with the business logic.

DataViewer is separated from the BLL layer in the original dynamic software three-layer architecture and is responsible for providing data to the front-end page. It should belong to the presentation layer. In this way, the layers are much clearer. BLL is only responsible for processing business logic and does not provide data displayed on the frontend. In other words, the BLL layer is responsible for modifying the back-end database, while DataViewer is not responsible for modifying the database. It is only responsible for reading the database and outputting Combined Query and paging data to the front-end.

DataViewer does not use HQL of nhib1_because HQL may cause low efficiency. It uses the original SQL query method and does not need to learn new things. It can also perform some query optimization. DataViewer is preferably an operation view, which is easy to modify without operating a specific table.

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.