<%@ 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;
}
<% } %>
}
}
Photoshop|
Dreamweaver|
SVG|
WebGL|
Visual Studio|
PowerDesigner|
Eclipse|
Git|
Apache Ant|
Atom|
Composer|
CodeSmith|
Flex|
Gradle|
Maven|
Sublime Text3|
SVN|
Tableau|
Vim|
Chrome开发者工具|
OpenGL|
Unity|
Direct3D|
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....