Reflection has been & quot; Out & quot;, dynamic compilation can be & quot; Hold & quot;

Source: Internet
Author: User

 

Net supports the reflection function, it really makes our Net program shine, it is amazing, just need to input strings to complete the function. it can be said that the introduction of the reflection function makes us more comfortable in dealing with certain problems.

In traditional database management software, frequent changes to database fields and constant changes to the Front-End Entity classes pose a headache. it doesn't mean that the Db structure we designed is unreasonable, and the customer's requirements change frequently and are uncontrollable. Of course, if you are very proficient in the industry, you can avoid this problem.

Although the reflection function can be used to pass in strings to solve some problems, if you encounter the problem of adding or deleting database fields mentioned above, our common method is to write the upgraded SQL statement to the customer, then, after the company modifies the entity class in a DLL file, recompile it, and package and test it. send the foreground DLL file and the background SQL statement to each household. The implementer or the customer's System Administrator overwrites the latest file and generates the SQL statement, the reflection function is used to generate object class objects.

The entire process is basically the same. The process of re-generating DLL files seems much easier if dynamic compilation is used. The general idea is as follows:

1. The steps for modifying the database table structure remain unchanged.

2. generate DLL files and use dynamic compilation. that is, when the system opens, the entity class is generated based on the object in the Db, and then the DLL file is compiled and generated directly. Compared with the previous method, the DLL compilation process is automatically executed by the system, we do not need to compile in the company. in this way, we only need to ensure that the SQL statement upgrade is correct.

3. Based on the generated DLL file, we can use reflection again.

Of course, the function of dynamic compilation is far more than that, for example, generating a NET string and performing dynamic code. if you are interested in children's shoes, you can search for them in the blog garden. Here we recommend this article, which is really good.

Address: http://www.cnblogs.com/lichdr/archive/2004/10/20/54569.html

The other method for implementing dynamic compilation is very simple, as shown in-1. There is a complete method in the downloaded file provided by me, just use it directly.

Figure-1

Let's take a look at how to use this method to compile files. Now we implement such a business. The customer needs to add a new table, and the corresponding entities also need to be added, add, delete, modify, and query objects. -as shown in figure 2, you must first create a string for the object class.

Figure 2

Then compile it directly. If the compilation is successful, we can directly operate on it using reflection.-3 shows

Figure-3

What is the effect? In this case, if we encounter similar requirements, we need to provide strings instead of generating DLL in the company, which is covered by the implementer.

Technological updates make it easier and easier for us to deal with certain problems.

 

Source File

Http://www.bkjia.com/uploadfile/2011/1101/20111101011906735.rar

 

Author Vincent. Q

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.