You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.1 KiB
82 lines
2.1 KiB
1 year ago
|
|
||
|
<%@ CodeTemplate Language="C#" ClassName="TableSQL" TargetLanguage="C#" Debug="False" Description="" encoding="GB2312" %>
|
||
|
<%@ Property Name="databaseProjectName" Type="System.String" Default="SpSampleDb" Optional="True" Category="Context" Description="" %>
|
||
|
<%@ Property Name="nameSpace" Type="System.String" Default="sql" Optional="True" Category="Context" Description="" %>
|
||
|
|
||
|
/*******************************************************/
|
||
|
/*Create table */
|
||
|
/*******************************************************/
|
||
|
<%
|
||
|
DbEntity db = Template.GetDataBase(databaseProjectName);
|
||
|
OpenResponse(databaseProjectName+"\\database.sql");
|
||
|
foreach(Table tb in db.Tables)
|
||
|
{
|
||
|
|
||
|
string pkParmList = "";
|
||
|
foreach(Field fd in tb.Fields)
|
||
|
{
|
||
|
if(fd.IsPK == true)
|
||
|
pkParmList += fd.DataType.DotNetType+" "+fd.MemberName+",";
|
||
|
}
|
||
|
pkParmList = pkParmList.Trim(',');
|
||
|
|
||
|
|
||
|
string tablename=tb.TableSpace.ToLower() +tb.MemberName.ToLower();
|
||
|
|
||
|
Response.WriteLine("-- ----------------------------");
|
||
|
Response.WriteLine("-- " + tb.CnName+" " );
|
||
|
Response.WriteLine("-- ----------------------------");
|
||
|
Response.Write("DROP TABLE IF EXISTS ");
|
||
|
Response.Write(tablename);
|
||
|
Response.WriteLine(";");
|
||
|
Response.WriteLine("create table " + tablename+" (" );
|
||
|
|
||
|
int icount=0;
|
||
|
foreach(Field fd in tb.Fields)
|
||
|
{
|
||
|
|
||
|
|
||
|
if(icount>0){
|
||
|
Response.WriteLine(" ," );
|
||
|
}
|
||
|
string filename=fd.MemberName.ToLower();
|
||
|
|
||
|
Response.Write(" "+ filename+" "+ fd.DataType.FullName );
|
||
|
|
||
|
if(fd.Identity.ToString()!=""){
|
||
|
Response.Write( " auto_increment primary key" );
|
||
|
}else{
|
||
|
|
||
|
if(fd.IsPK == true){
|
||
|
Response.Write( " primary key " );
|
||
|
}}
|
||
|
|
||
|
if(fd.DefaultValue != ""){
|
||
|
Response.Write( " default '"+fd.DefaultValue+"' " );
|
||
|
}
|
||
|
if(fd.IsNullable == true){
|
||
|
Response.Write( " null " );
|
||
|
}else{
|
||
|
Response.Write( " not null " );
|
||
|
}
|
||
|
Response.Write( " COMMENT '" );
|
||
|
Response.Write( fd.CnName);
|
||
|
Response.Write( "' " );
|
||
|
icount++;
|
||
|
|
||
|
|
||
|
}
|
||
|
Response.WriteLine("");
|
||
|
%>
|
||
|
);
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<%
|
||
|
}
|
||
|
CloseResponse();
|
||
|
%>
|