subsonic 3.0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/LICENSE.txt +41 -0
- data/lib/SubSonic.Core.dll +0 -0
- data/lib/T4 Templates/ActiveRecord/ActiveRecord.tt +620 -0
- data/lib/T4 Templates/ActiveRecord/Context.tt +295 -0
- data/lib/T4 Templates/ActiveRecord/SQLServer.ttinclude +347 -0
- data/lib/T4 Templates/ActiveRecord/Settings.ttinclude +552 -0
- data/lib/T4 Templates/ActiveRecord/StoredProcedures.tt +30 -0
- data/lib/T4 Templates/ActiveRecord/Structs.tt +67 -0
- data/lib/T4 Templates/LinqTemplates/Classes.tt +117 -0
- data/lib/T4 Templates/LinqTemplates/Context.tt +276 -0
- data/lib/T4 Templates/LinqTemplates/SQLServer.ttinclude +349 -0
- data/lib/T4 Templates/LinqTemplates/Settings.ttinclude +551 -0
- data/lib/T4 Templates/LinqTemplates/StoredProcedures.tt +30 -0
- data/lib/T4 Templates/LinqTemplates/Structs.tt +67 -0
- data/lib/T4 Templates/README.txt +7 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/ActiveRecord/ActiveRecord.tt +560 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/ActiveRecord/ActiveRecord.vb +6447 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/ActiveRecord/Context.tt +258 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/ActiveRecord/Context.vb +349 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/ActiveRecord/SQLServer.ttinclude +332 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/ActiveRecord/Settings.ttinclude +550 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/ActiveRecord/StoredProcedures.tt +30 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/ActiveRecord/StoredProcedures.vb +55 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/ActiveRecord/Structs.tt +57 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/ActiveRecord/Structs.vb +1478 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/ActiveRecord/Tests/FetchTests.vb +52 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/App.config +9 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/My Project/Application.Designer.vb +13 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/My Project/Application.myapp +10 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/My Project/AssemblyInfo.vb +35 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/My Project/Resources.Designer.vb +63 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/My Project/Resources.resx +117 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/My Project/Settings.Designer.vb +73 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/My Project/Settings.settings +7 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/SubSonic.TemplatesVB.vbproj +171 -0
- data/lib/T4 Templates/SubSonic.TemplatesVB/SubSonic.TemplatesVB.vbproj.user +5 -0
- data/lib/T4 Templates/TemplateProviders/MySQL.ttinclude +278 -0
- data/lib/T4 Templates/TemplateProviders/MySQL.ttinclude.orig +303 -0
- data/lib/T4 Templates/TemplateProviders/MySQLTest.tt +27 -0
- data/lib/T4 Templates/TemplateProviders/SQLite.ttinclude +194 -0
- data/lib/T4 Templates/TemplateProviders/SQLite.ttinclude.orig +236 -0
- data/lib/T4 Templates/TemplateProviders/SQLiteTest.tt +27 -0
- data/lib/T4 Templates/TemplateProviders/Settings.ttinclude +551 -0
- metadata +112 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
<#@ template language="C#v3.5" debug="False" hostspecific="True" #>
|
2
|
+
<#@ output extension=".cs" #>
|
3
|
+
<#@ include file="MySQL.ttinclude" #>
|
4
|
+
<#
|
5
|
+
var tables = LoadTables();
|
6
|
+
|
7
|
+
foreach(var tbl in tables){
|
8
|
+
#>
|
9
|
+
//***********************************************
|
10
|
+
//Table=<#=tbl.Name#>
|
11
|
+
//Columns=<#=tbl.Columns.Count#>
|
12
|
+
//PK =<#=tbl.PK.Name#>
|
13
|
+
//FKs = <#=tbl.FKTables.Count#>;
|
14
|
+
|
15
|
+
|
16
|
+
<# foreach(var col in tbl.Columns){#>
|
17
|
+
//<#=col.Name#> (<#=col.SysType#>): Nullable: <#=col.IsNullable#>
|
18
|
+
<# }#>
|
19
|
+
|
20
|
+
//FKs
|
21
|
+
<# foreach(var fk in tbl.FKTables){#>
|
22
|
+
//<#=fk.ThisTable#> --> <#=fk.OtherTable#>
|
23
|
+
<# }#>
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
<# }#>
|
@@ -0,0 +1,194 @@
|
|
1
|
+
<#@ include file="Settings.ttinclude" #>
|
2
|
+
<#@ assembly name="System.Data.SQLite" #>
|
3
|
+
<#@ import namespace="System.Data.SQLite" #>
|
4
|
+
<#@ import namespace="System.Diagnostics" #>
|
5
|
+
<#+
|
6
|
+
SQLiteConnection conn;
|
7
|
+
|
8
|
+
|
9
|
+
List<Table> LoadTables(){
|
10
|
+
var result=new List<Table>();
|
11
|
+
|
12
|
+
using(conn=new SQLiteConnection(ConnectionString)){
|
13
|
+
|
14
|
+
conn.Open();
|
15
|
+
//this will return everything for the DB
|
16
|
+
var schema = conn.GetSchema("COLUMNS");
|
17
|
+
conn.Close();
|
18
|
+
|
19
|
+
//spin through once to get all the tables
|
20
|
+
foreach (DataRow row in schema.Rows)
|
21
|
+
{
|
22
|
+
if(!result.Any(x=>x.Name.Equals(row["TABLE_NAME"].ToString(),StringComparison.InvariantCultureIgnoreCase)))
|
23
|
+
{
|
24
|
+
|
25
|
+
//add it
|
26
|
+
Table tbl = new Table();
|
27
|
+
tbl.PrimaryKey="";
|
28
|
+
tbl.FKTables=new List<FKTable>();
|
29
|
+
tbl.Name = row["TABLE_NAME"].ToString();
|
30
|
+
tbl.CleanName=CleanUp(tbl.Name);
|
31
|
+
tbl.ClassName=Inflector.MakeSingular(tbl.CleanName);
|
32
|
+
tbl.QueryableName=Inflector.MakePlural(tbl.ClassName);
|
33
|
+
result.Add(tbl);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
//loop again - but this time pull by table name
|
38
|
+
foreach (var item in result) {
|
39
|
+
item.Columns=new List<Column>();
|
40
|
+
//pull the columns from the schema
|
41
|
+
var columns = schema.Select("TABLE_NAME='" + item.Name + "'");
|
42
|
+
|
43
|
+
foreach (var row in columns) {
|
44
|
+
Column col=new Column();
|
45
|
+
col.Name=row["COLUMN_NAME"].ToString();
|
46
|
+
col.CleanName=CleanUp(col.Name);
|
47
|
+
col.DataType=row["DATA_TYPE"].ToString();
|
48
|
+
|
49
|
+
col.SysType=GetSysType(col.DataType);
|
50
|
+
col.DbType=GetDbType(col.DataType);
|
51
|
+
|
52
|
+
col.AutoIncrement=row["AUTOINCREMENT"].ToString()=="True";
|
53
|
+
col.IsNullable=row["IS_NULLABLE"].ToString()=="True";
|
54
|
+
col.IsPK=row["PRIMARY_KEY"].ToString()=="True";
|
55
|
+
|
56
|
+
if(col.IsPK){
|
57
|
+
item.PrimaryKey=col.Name ?? "";
|
58
|
+
}
|
59
|
+
|
60
|
+
int.TryParse(row["CHARACTER_MAXIMUM_LENGTH"].ToString(),out col.MaxLength);
|
61
|
+
|
62
|
+
item.Columns.Add(col);
|
63
|
+
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
return result;
|
71
|
+
}
|
72
|
+
|
73
|
+
string GetSysType(string sqlType)
|
74
|
+
{
|
75
|
+
|
76
|
+
switch (sqlType)
|
77
|
+
{
|
78
|
+
|
79
|
+
case "bigint":
|
80
|
+
case "smallint":
|
81
|
+
case "int":
|
82
|
+
return "int";
|
83
|
+
|
84
|
+
case "long":
|
85
|
+
case "integer":
|
86
|
+
return "long";
|
87
|
+
|
88
|
+
case "guid":
|
89
|
+
return "Guid";
|
90
|
+
|
91
|
+
case "smalldatetime":
|
92
|
+
case "datetime":
|
93
|
+
return "DateTime";
|
94
|
+
|
95
|
+
case "float":
|
96
|
+
return "double";
|
97
|
+
|
98
|
+
case "real":
|
99
|
+
case "numeric":
|
100
|
+
case "smallmoney":
|
101
|
+
case "decimal":
|
102
|
+
case "money":
|
103
|
+
return "decimal";
|
104
|
+
|
105
|
+
case "tinyint":
|
106
|
+
case "bit":
|
107
|
+
return "bool";
|
108
|
+
|
109
|
+
case "blob":
|
110
|
+
case "image":
|
111
|
+
case "binary":
|
112
|
+
case "varbinary":
|
113
|
+
return "byte[]";
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
return "string";
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
DbType GetDbType(string sqlType){
|
122
|
+
switch(sqlType)
|
123
|
+
{
|
124
|
+
case "varchar":
|
125
|
+
return DbType.AnsiString;
|
126
|
+
|
127
|
+
case "nvarchar":
|
128
|
+
return DbType.String;
|
129
|
+
|
130
|
+
case "int":
|
131
|
+
return DbType.Int32;
|
132
|
+
|
133
|
+
case "integer":
|
134
|
+
return DbType.Int64;
|
135
|
+
|
136
|
+
case "long":
|
137
|
+
return DbType.Int64;
|
138
|
+
|
139
|
+
case "guid":
|
140
|
+
return DbType.Guid;
|
141
|
+
|
142
|
+
case "datetime":
|
143
|
+
return DbType.DateTime;
|
144
|
+
|
145
|
+
case "bigint":
|
146
|
+
return DbType.Int64;
|
147
|
+
|
148
|
+
case "binary":
|
149
|
+
case "blob":
|
150
|
+
case "image":
|
151
|
+
case "timestamp":
|
152
|
+
case "varbinary":
|
153
|
+
return DbType.Binary;
|
154
|
+
|
155
|
+
case "bit":
|
156
|
+
return DbType.Boolean;
|
157
|
+
case "char":
|
158
|
+
return DbType.AnsiStringFixedLength;
|
159
|
+
case "decimal":
|
160
|
+
return DbType.Decimal;
|
161
|
+
case "float":
|
162
|
+
return DbType.Double;
|
163
|
+
case "money":
|
164
|
+
return DbType.Currency;
|
165
|
+
case "nchar":
|
166
|
+
return DbType.String;
|
167
|
+
case "ntext":
|
168
|
+
return DbType.String;
|
169
|
+
case "numeric":
|
170
|
+
return DbType.Decimal;
|
171
|
+
case "real":
|
172
|
+
return DbType.Single;
|
173
|
+
case "smalldatetime":
|
174
|
+
return DbType.DateTime;
|
175
|
+
case "smallint":
|
176
|
+
return DbType.Int16;
|
177
|
+
case "smallmoney":
|
178
|
+
return DbType.Currency;
|
179
|
+
case "sql_variant":
|
180
|
+
return DbType.String;
|
181
|
+
case "sysname":
|
182
|
+
return DbType.String;
|
183
|
+
case "text":
|
184
|
+
return DbType.AnsiString;
|
185
|
+
case "tinyint":
|
186
|
+
return DbType.Byte;
|
187
|
+
|
188
|
+
default:
|
189
|
+
return DbType.AnsiString;
|
190
|
+
}
|
191
|
+
|
192
|
+
}
|
193
|
+
|
194
|
+
#>
|
@@ -0,0 +1,236 @@
|
|
1
|
+
<#@ include file="Settings.ttinclude" #>
|
2
|
+
<#@ assembly name="System.Data.SQLite" #>
|
3
|
+
<#@ import namespace="System.Data.SQLite" #>
|
4
|
+
<#@ import namespace="System.Diagnostics" #>
|
5
|
+
<#+
|
6
|
+
SQLiteConnection conn;
|
7
|
+
|
8
|
+
|
9
|
+
List<Table> LoadTables(){
|
10
|
+
var result=new List<Table>();
|
11
|
+
|
12
|
+
using(conn=new SQLiteConnection(ConnectionString)){
|
13
|
+
|
14
|
+
conn.Open();
|
15
|
+
//this will return everything for the DB
|
16
|
+
var schema = conn.GetSchema("COLUMNS");
|
17
|
+
conn.Close();
|
18
|
+
|
19
|
+
//spin through once to get all the tables
|
20
|
+
foreach (DataRow row in schema.Rows)
|
21
|
+
{
|
22
|
+
if(!result.Any(x=>x.Name.Equals(row["TABLE_NAME"].ToString(),StringComparison.InvariantCultureIgnoreCase)))
|
23
|
+
{
|
24
|
+
|
25
|
+
//add it
|
26
|
+
Table tbl = new Table();
|
27
|
+
tbl.PrimaryKey="";
|
28
|
+
tbl.FKTables=new List<FKTable>();
|
29
|
+
tbl.Name = row["TABLE_NAME"].ToString();
|
30
|
+
tbl.CleanName=CleanUp(tbl.Name);
|
31
|
+
tbl.ClassName=Inflector.MakeSingular(tbl.CleanName);
|
32
|
+
tbl.QueryableName=Inflector.MakePlural(tbl.ClassName);
|
33
|
+
result.Add(tbl);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
//loop again - but this time pull by table name
|
38
|
+
foreach (var item in result) {
|
39
|
+
item.Columns=new List<Column>();
|
40
|
+
//pull the columns from the schema
|
41
|
+
var columns = schema.Select("TABLE_NAME='" + item.Name + "'");
|
42
|
+
|
43
|
+
foreach (var row in columns) {
|
44
|
+
Column col=new Column();
|
45
|
+
col.Name=row["COLUMN_NAME"].ToString();
|
46
|
+
col.CleanName=CleanUp(col.Name);
|
47
|
+
col.DataType=row["DATA_TYPE"].ToString();
|
48
|
+
|
49
|
+
col.SysType=GetSysType(col.DataType);
|
50
|
+
col.DbType=GetDbType(col.DataType);
|
51
|
+
|
52
|
+
col.AutoIncrement=row["AUTOINCREMENT"].ToString()=="True";
|
53
|
+
col.IsNullable=row["IS_NULLABLE"].ToString()=="True";
|
54
|
+
col.IsPK=row["PRIMARY_KEY"].ToString()=="True";
|
55
|
+
|
56
|
+
if(col.IsPK){
|
57
|
+
item.PrimaryKey=col.Name ?? "";
|
58
|
+
}
|
59
|
+
|
60
|
+
int.TryParse(row["CHARACTER_MAXIMUM_LENGTH"].ToString(),out col.MaxLength);
|
61
|
+
|
62
|
+
item.Columns.Add(col);
|
63
|
+
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
return result;
|
71
|
+
}
|
72
|
+
|
73
|
+
<<<<<<< HEAD
|
74
|
+
string GetSysType(string sqlType){
|
75
|
+
string sysType="string";
|
76
|
+
switch (sqlType) {
|
77
|
+
case "bigint":
|
78
|
+
case "smallint":
|
79
|
+
case "int":
|
80
|
+
sysType= "int";
|
81
|
+
break;
|
82
|
+
case "long":
|
83
|
+
case "integer":
|
84
|
+
sysType= "long";
|
85
|
+
case "guid":
|
86
|
+
sysType= "Guid";
|
87
|
+
break;
|
88
|
+
case "smalldatetime":
|
89
|
+
case "datetime":
|
90
|
+
sysType= "DateTime";
|
91
|
+
break;
|
92
|
+
case "float":
|
93
|
+
sysType="double";
|
94
|
+
break;
|
95
|
+
case "real":
|
96
|
+
case "numeric":
|
97
|
+
case "smallmoney":
|
98
|
+
case "decimal":
|
99
|
+
case "money":
|
100
|
+
sysType= "decimal";
|
101
|
+
break;
|
102
|
+
case "tinyint":
|
103
|
+
case "bit":
|
104
|
+
sysType= "boolean";
|
105
|
+
break;
|
106
|
+
case "image":
|
107
|
+
case "binary":
|
108
|
+
case "varbinary":
|
109
|
+
sysType= "byte[]";
|
110
|
+
break;
|
111
|
+
}
|
112
|
+
return sysType;
|
113
|
+
=======
|
114
|
+
string GetSysType(string sqlType)
|
115
|
+
{
|
116
|
+
|
117
|
+
switch (sqlType)
|
118
|
+
{
|
119
|
+
|
120
|
+
case "bigint":
|
121
|
+
case "smallint":
|
122
|
+
case "int":
|
123
|
+
return "int";
|
124
|
+
|
125
|
+
case "long":
|
126
|
+
case "integer":
|
127
|
+
return "long";
|
128
|
+
|
129
|
+
case "guid":
|
130
|
+
return "Guid";
|
131
|
+
|
132
|
+
case "smalldatetime":
|
133
|
+
case "datetime":
|
134
|
+
return "DateTime";
|
135
|
+
|
136
|
+
case "float":
|
137
|
+
return "double";
|
138
|
+
|
139
|
+
case "real":
|
140
|
+
case "numeric":
|
141
|
+
case "smallmoney":
|
142
|
+
case "decimal":
|
143
|
+
case "money":
|
144
|
+
return "decimal";
|
145
|
+
|
146
|
+
case "tinyint":
|
147
|
+
case "bit":
|
148
|
+
return "bool";
|
149
|
+
|
150
|
+
case "blob":
|
151
|
+
case "image":
|
152
|
+
case "binary":
|
153
|
+
case "varbinary":
|
154
|
+
return "byte[]";
|
155
|
+
|
156
|
+
}
|
157
|
+
|
158
|
+
return "string";
|
159
|
+
|
160
|
+
>>>>>>> b1f15d7a43e63916c03a365b4d260d43390f2689
|
161
|
+
}
|
162
|
+
|
163
|
+
DbType GetDbType(string sqlType){
|
164
|
+
switch(sqlType)
|
165
|
+
{
|
166
|
+
case "varchar":
|
167
|
+
return DbType.AnsiString;
|
168
|
+
|
169
|
+
case "nvarchar":
|
170
|
+
return DbType.String;
|
171
|
+
|
172
|
+
case "int":
|
173
|
+
return DbType.Int32;
|
174
|
+
|
175
|
+
case "integer":
|
176
|
+
return DbType.Int64;
|
177
|
+
|
178
|
+
case "long":
|
179
|
+
return DbType.Int64;
|
180
|
+
|
181
|
+
case "guid":
|
182
|
+
return DbType.Guid;
|
183
|
+
|
184
|
+
case "datetime":
|
185
|
+
return DbType.DateTime;
|
186
|
+
|
187
|
+
case "bigint":
|
188
|
+
return DbType.Int64;
|
189
|
+
|
190
|
+
case "binary":
|
191
|
+
case "blob":
|
192
|
+
case "image":
|
193
|
+
case "timestamp":
|
194
|
+
case "varbinary":
|
195
|
+
return DbType.Binary;
|
196
|
+
|
197
|
+
case "bit":
|
198
|
+
return DbType.Boolean;
|
199
|
+
case "char":
|
200
|
+
return DbType.AnsiStringFixedLength;
|
201
|
+
case "decimal":
|
202
|
+
return DbType.Decimal;
|
203
|
+
case "float":
|
204
|
+
return DbType.Double;
|
205
|
+
case "money":
|
206
|
+
return DbType.Currency;
|
207
|
+
case "nchar":
|
208
|
+
return DbType.String;
|
209
|
+
case "ntext":
|
210
|
+
return DbType.String;
|
211
|
+
case "numeric":
|
212
|
+
return DbType.Decimal;
|
213
|
+
case "real":
|
214
|
+
return DbType.Single;
|
215
|
+
case "smalldatetime":
|
216
|
+
return DbType.DateTime;
|
217
|
+
case "smallint":
|
218
|
+
return DbType.Int16;
|
219
|
+
case "smallmoney":
|
220
|
+
return DbType.Currency;
|
221
|
+
case "sql_variant":
|
222
|
+
return DbType.String;
|
223
|
+
case "sysname":
|
224
|
+
return DbType.String;
|
225
|
+
case "text":
|
226
|
+
return DbType.AnsiString;
|
227
|
+
case "tinyint":
|
228
|
+
return DbType.Byte;
|
229
|
+
|
230
|
+
default:
|
231
|
+
return DbType.AnsiString;
|
232
|
+
}
|
233
|
+
|
234
|
+
}
|
235
|
+
|
236
|
+
#>
|