Codesmith (5) accessing the database

Source: Internet
Author: User

Codesmith accesses the database. The template is as follows:

 

 

Code

< % @ Codetemplate Language = "C #" Inherits = "Codesmith. basetemplates. sqlcodetemplate" Targetlanguage = "T-SQL" Description = "Generates select/insert/update/delete stored procedure based on a database schema ." % >
< % @ Property Name = "Sourcedatabase" Type = "Schemaexplorer. databaseschema" Category = "Context" Description = "Database that the stored procedures shoshould be based on ." % >
< % @ Assembly Name = "Schemaexplorer" % >
< % @ Assembly Name = "Codesmith. basetemplates" % >
< % @ Import Namespace = "Schemaexplorer" % >
< %
For (INT I = 0; I {< br>
response. writeline ("-- skipping" + sourcedatabase. tables [I]. name);

}< br> % >

references <% @ Assembly name = "schemaexplorer" %>
<% @ Assembly name = "codesmith. basetemplates "%>
<% @ import namespace =" schemaexplorer "%> Program set.
then the attribute type is declared as schemaexplorer. databaseschema attributes (database ).
later, according to sourcedatabase. tables: obtains the set of all tables of the database.
sourcedatabase. tables. count: obtain the number of database tables
sourcedatabase. tables [I]: Obtain the I table
sourcedatabase. tables [I]. name: Obtain the table name of Table I.

original works are self-worked and lazy, reprinted please explain the source of the article: http://www.cnblogs.com/kfarvid/

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.