<% --
Name: dd
Author: Binbin
Description: booksir
-- %>
<% @ Codetemplate Language = "C #" targetlanguage = "text" src = "" inherits = "" DEBUG = "false" Description = "template description here." %>
<% @ Assembly name = "schemaexplorer" %>
<% @ Import namespace = "schemaexplorer" %>
<% @ Assembly name = "system. Data" %>
<% @ Import namespace = "system. Data" %>
<% @ Property name = "sourcetable" type = "schemaexplorer. tableschema" Category = "context" Description = "select a table" %>
<% @ Property name = "namespace" type = "system. string "default =" somevalue "Optional =" true "Category =" strings "Description =" program namespace "%>
Using system;
Using system. Web;
Using system. Data;
Namespace <% = namespace %>
{
Public class <% = onetoupper (sourcetable. Name) %> info
{
<% For (INT I = 0; I <sourcetable. Columns. Count; I ++) {%>
Private <% = getcsharpvariabletype (sourcetable. Columns [I]) % >_< % = onetolower (sourcetable. Columns [I]. Name) %>;
<% }%>
<% For (INT I = 0; I <sourcetable. Columns. Count; I ++) {%>
Public <% = getcsharpvariabletype (sourcetable. Columns [I]) %> <% = onetoupper (sourcetable. Columns [I]. Name) %>
{
Get {return _ <% = onetolower (sourcetable. Columns [I]. Name) %> ;}
Set {_ <% = onetolower (sourcetable. Columns [I]. Name) %> = value ;}
}
<% }%>
}
}
<SCRIPT runat = "template">
// Uppercase letters
Private string onetoupper (string Str)
{
Return Str. substring (0, 1). toupper () + Str. substring (1 );
}
// Lowercase for the first letter
Private string onetolower (string Str)
{
Return Str. substring (0, 1). tolower () + Str. substring (1 );
}
Public String getcsharpvariabletype (columnschema column)
{
If (column. Name. endswith ("typecode") return column. Name;
Switch (column. datatype)
{
Case dbtype. ansistring: Return "string ";
Case dbtype. ansistringfixedlength: Return "string ";
Case dbtype. Binary: Return "byte []";
Case dbtype. boolean: Return "bool ";
Case dbtype. byte: Return "Byte ";
Case dbtype. Currency: Return "decimal ";
Case dbtype. Date: Return "datetime ";
Case dbtype. datetime: Return "datetime ";
Case dbtype. Decimal: Return "decimal ";
Case dbtype. Double: Return "double ";
Case dbtype. guid: Return "guid ";
Case dbtype. int16: Return "short ";
Case dbtype. int32: Return "int ";
Case dbtype. int64: Return "long ";
Case dbtype. Object: Return "object ";
Case dbtype. sbyte: Return "sbyte ";
Case dbtype. Single: Return "float ";
Case dbtype. String: Return "string ";
Case dbtype. stringfixedlength: Return "string ";
Case dbtype. Time: Return "timespan ";
Case dbtype. uint16: Return "ushort ";
Case dbtype. uint32: Return "uint ";
Case dbtype. uint64: Return "ulong ";
Case dbtype. varnumeric: Return "decimal ";
Default:
{
Return "_ Unknown _" + column. nativetype;
}
}
}
</SCRIPT>