<%@ CodeTemplate Language="C#" TargetLanguage="Text" Src="" Inherits="" Debug="False" Description="Template description here." %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Property Name="SourceDatabase" Type="SchemaExplorer.DatabaseSchema" DeepLoad="True" Optional="False" Category="01. GettingStarted - Required" Description="Database that the tables views, and storedprocedures should be based on. IMPORTANT!!! If SourceTables and SourceViews areleft blank, the Entire Database will then be generated." %>
<%-- 注册实体层Entity模板 --%>
<%@ Register Name="EntityTemplate" Template="Entity.cst" MergeProperties="Flase" ExcludeProperties="" %>
<script runat="template">
//解决方案输出路径
private string Directory = String.Empty;
[Editor(typeof(System.Windows.Forms.Design.FolderNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
[Optional, NotChecked]
[DefaultValue("")]
public string OutputDirectory
{
get
{
return Directory;
}
set
{
if (value.EndsWith("\\")) value = value.Substring(0, value.Length - 1);
Directory = value;
}
}
</script>
<script runat="template">
//生成实体Entity类
private void GenerateEntityClasses()
{
CodeTemplate Template = new EntityTemplate();
foreach(TableSchema table in this.SourceDatabase.Tables)
{
string FileDirectory = OutputDirectory + "\\" + table.Name + ".cs";
//生成模板
Template.SetProperty("Table",table);
//文件输出
Template.RenderToFile(FileDirectory,true);
Debug.WriteLine(FileDirectory +" 创建成功.");
}
}
</script>
<%
//创建实体层Entity类
this.GenerateEntityClasses();
Debug.WriteLine("OK");
%>
Entity.cst文件内容
------------------------开始---------------------------------------------
<%@ CodeTemplate Inherits="CodeTemplate" Language="C#" TargetLanguage="Text" Description="NetTiers main template." Debug="True" ResponseEncoding="UTF-8"%>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%-- 要打印的表 --%>
<%@ Property Name="Table" DeepLoad="True" Type="TableSchema" Optional="False" Category="01. Getting Started - Required"Description="Database that the tables views, and stored procedures shouldbe based on. IMPORTANT!!! If SourceTables and SourceViews are left blank, theEntire Database will then be generated." %>
<%--测试版本,要是使用需要修改 --%>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Entity
{
public partial class <%= Table.Name%>
{
<% foreach(ColumnSchema col in Table.Columns){ %>
public <%= col.DataType %> <%=col.Name %>
{
get;
set;
}
<% } %>
}
}
热门文章更多>>
标签更多>>
专题更多>>
最新文章更多>>
- 华为m3和ipad air2哪个好?华为平板m3和ipad air2详细区别对比评测
- 华为平板M3怎么调节色温保护眼睛?
- 8.4英寸华为平板M3真机图赏:主打影音视频和游戏
- 华为平板M3怎么使用自带的云服务导入旧手机资料数据?
- 怎么将之前手机中的就资料导入华为平板M3?
- 华硕ZenPad 3S 10值得买吗?华硕ZenPad 3S 10平板全面评测
- 小米平板2的16G内存够用吗? 16GB版小米平板2可以刷Win10系统吗?
- 华为平板M3值得买吗 华为平板M3全面评测图解
- 华为平板M3和小米平板2哪个好?小米平板2和华为平板M3详细区别对比评测
- 华为平板M3有几个版本?华为平板M3 WiFi版与LTE版各版本区别对比评测