In the previous article I introduced the use of attributes to describe business objects. In this article I will show you how to extract descriptive information from a class. To explain how it works, I'll create a SQL script to generate the table using the attributes I used earlier in the class to write an application.
Tools
This is a console application. The tool will load the assembly and enumerate the attibute generated SQL scripts used by the class to create the table.
Console.WriteLine ("Failed to load assembly [" + Args[0] + "]");
Console.WriteLine (E.message);
}
}
The code above attempts to load the assembly with the parameter path. Now we have to enumerate all the components containing the DataTable. To complete this work, see the following code:
Now we have to create the SQL script. Our tools only meet 2 requirements: Key is Int,identify property type only these are allowed: String,int,decimal, and DateTime.
The source file will create the following assembly:
DAL.dll: Contains attributes
Customer.dll: Contains Business objects
ScriptGen.exe: The tool used to generate SQL scripts.
Next
Next, I'll create the entire DAL, which is used to get objects at run time and so on.
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.