-
Notifications
You must be signed in to change notification settings - Fork 0
/
Structs.tt
67 lines (54 loc) · 1.9 KB
/
Structs.tt
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<#@ template language="C#v3.5" debug="False" hostspecific="True" #>
<#@ output extension=".cs" #>
<#@ include file="SQLServer.ttinclude" #>
<#
var tables = LoadTables();
#>
using System;
using SubSonic.Schema;
using System.Collections.Generic;
using SubSonic.DataProviders;
using System.Data;
namespace <#=Namespace#> {
<# foreach(var tbl in tables){
if(!ExcludeTables.Contains(tbl.Name))
{
#>
/// <summary>
/// Table: <#=tbl.Name#>
/// Primary Key: <#=tbl.PrimaryKey#>
/// </summary>
public class <#=tbl.CleanName#>Table: DatabaseTable {
public <#=tbl.CleanName#>Table(IDataProvider provider):base("<#=tbl.Name#>",provider){
ClassName = "<#=tbl.ClassName#>";
SchemaName = "<#=tbl.Schema ?? ""#>";
<# foreach(var col in tbl.Columns){#>
Columns.Add(new DatabaseColumn("<#=col.Name#>", this)
{
IsPrimaryKey = <#=col.IsPK.ToString().ToLower()#>,
DataType = DbType.<#=col.DbType.ToString()#>,
IsNullable = <#=col.IsNullable.ToString().ToLower()#>,
AutoIncrement = <#=col.AutoIncrement.ToString().ToLower()#>,
IsForeignKey = <#=col.IsForeignKey.ToString().ToLower()#>,
MaxLength = <#=col.MaxLength#>
});
<# }#>
}
<# foreach(var col in tbl.Columns){#>
public IColumn <#=col.CleanName#>{
get{
return this.GetColumn("<#=col.Name#>");
}
}
public static string <#= col.CleanName #>Column{
get{
return "<#= col.Name #>";
}
}
<# }#>
}
<#
}
}
#>
}