小隐的博客

人生在世,笑饮一生 QQ:178852134
posts - 57, comments - 56, trackbacks - 14, articles - 0
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

<%--
Name:
Author:
Description:
--%>
<%@ CodeTemplate Language="C#" TargetLanguage="Text" Src="" Inherits="" Debug="ture" Description="Template description here." %>
<%@ Property Name="DataBase" Type="SchemaExplorer.DatabaseSchema" %>
<%@ Property Name="pre_Context" Type="System.String" %>
<%@ Property Name="edit_Context" Type="System.String" %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Assembly Name="System.Data" %>
<%@ Import Namespace="System.Data" %>

<%= find()%>

<script runat="template">
string find()
{
 string result ="";
 foreach(TableSchema table in this.DataBase.Tables)
 {
  
  if(table.HasPrimaryKey)
  {
  string[] Keys = new string[table.PrimaryKey.MemberColumns.Count];
  for(int keycount = 0;keycount < table.PrimaryKey.MemberColumns.Count;keycount ++)
  {
   Keys[keycount] = table.PrimaryKey.MemberColumns[keycount].Name;
  }
  DataTable datatable = table.GetTableData();
  
  foreach(ColumnSchema column in table.Columns)
  {
   foreach(System.Data.DataRow row in datatable.Rows)
   {
    string str = row[column.Name].ToString();
    
    if(str.IndexOf(pre_Context) >= 0)
    {
     result += "update " + table.Name + "\r\n" + " set " +
     column.Name + "=" + "'" +
     str.ToString().Replace(pre_Context,edit_Context) + "'\r\n" + " where " +
     "1=1 ";
     foreach(string key in Keys)
     {
      result += "and " + key + "= '" + row[key].ToString() + "'";
     }
     result += "\r\n" + "GO" + "\r\n";
    }
   }
  }
  }
 }
 return result;
}
</script>

Feedback

#1楼    回复  引用  查看    

2008-01-15 14:05 by Q.Lee.lulu      
怎么一个文字都没有 ???

#2楼    回复  引用  查看    

2008-01-19 13:27 by 张荣华      
http://www.cnblogs.com/zhangronghua/archive/2008/01/19/1045349.html
基于Sql语句生成实体类和数据库操作类(crud操作)的codesmith模板

标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交