posts - 609,  comments - 13,  views - 64万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

模板是C#语法的 .cst文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<%@ CodeTemplate Language="C#" TargetLanguage="Text" ResponseEncoding="UTF-8" Src="" Inherits="" Debug="False" CompilerVersion="v3.5" Description="Template description here." %>
<%@ Property Name="ModelClassNameSpace" Type="System.String" Default="ModelClassNameSpace" Optional="False" Category="Strings" Description="This is ModelClassNameSpace"%>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Import Namespace="System.Windows.Forms.Design" %>
<%@ Import Namespace="System.Drawing.Design" %>
<%@ Import Namespace="System.IO" %>
 
<script runat="template">
 
private DatabaseSchema _sourceDatabase;
[Category("Database")]
[Description("This is a DatabaseSource")]
public DatabaseSchema SourceDatabase
{
    get{return this._sourceDatabase;}
    set{_sourceDatabase= value;}
}
 
//设置类文件名称
public string GetClassName(TableSchema table)
{
    //if (table.Name.EndsWith("s"))
    //{
        //return table.Name.Substring(0, table.Name.Length - 1) + "Entity";
    //}
    //else
    //{
    //    return table.Name+"Entity";
    //}
    return FormatTable(table.Name);
}
//格式化表名
public string FormatTable(string param)
{
    string[] p =param.Split('_');
    return p[p.Length-1].ToString();
}
</script>
<%
foreach(TableSchema table in _sourceDatabase.Tables)
{
    %>
    //<%=table.Description%>
    kernel.Bind<ADT.Eppendorf.IBLL.APP.I<%=FormatTable(table.Name)%>>().To<ADT.Eppendorf.BLL.APP.<%=FormatTable(table.Name)%>>();
    kernel.Bind<ADT.Eppendorf.IDAL.APP.I<%=FormatTable(table.Name)%>>().To<ADT.Eppendorf.DAL.APP.<%=FormatTable(table.Name)%>>();
    <%
}
%>

  

posted on   邢帅杰  阅读(344)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】
点击右上角即可分享
微信分享提示