CodeSmith批量生成实体

保存以下文件为ModelBatch.cst 

 

<%@ Register Name="Model" Template="D:\Q\web\LHWYVISIT\trunk\CodeSmith.Template\DTO.cst" MergeProperties="False" ExcludeProperties="" %>
     
    <%@ Template Language="C#" TargetLanguage="Text" %>
    <%@ Property Name="BaseNamespace" Type="String" %>
    <%@ Property Name="OutPutDest" Type="String" %>
    <%@ Property Name="DB" Type="SchemaExplorer.DatabaseSchema" DeepLoad="True" Optional="False" Category="Context" Description="" %>
     
    <%@ Assembly Name="SchemaExplorer" %>
    <%@ Assembly Name="System.Design" %>
    <%@ Import Namespace="SchemaExplorer" %>
     
    <%
    CodeTemplate codeTemplate=new Model();
    codeTemplate.SetProperty("BaseNamespace",BaseNamespace);
    codeTemplate.SetProperty("SourceDatabase",DB);
    %>
     
     
    <%foreach(TableSchema tb in DB.Tables){
        codeTemplate.SetProperty("Table",tb);
        codeTemplate.RenderToFile(@"D:\Q\web\LHWYVISIT\trunk\CodeSmith.Template\M\"+CodeSmith.Extensions.TemplateEngine.GetCamelName(tb.Name)+"Dto.cs",true);
    } %>

posted @ 2016-07-20 13:39  甜菜波波  阅读(305)  评论(0编辑  收藏  举报