0
|
1 <#
|
|
2 //Rename tables and fields according to the .NET style, i.e. "booking_number" to "BookingNumber"
|
|
3 {
|
|
4 var fieldsPrevBeforeGenerateModel = BeforeGenerateModel;
|
|
5
|
|
6 Func<string, string> getNetStyleName = (string name) =>
|
|
7 {
|
|
8 if(!string.IsNullOrEmpty(name))
|
|
9 {
|
|
10 var chars = new System.Text.StringBuilder(name);
|
|
11 for(int i=1; i<chars.Length; i++)
|
|
12 if(chars[i-1]=='_') chars[i]=char.ToUpper(chars[i]);
|
|
13 chars.Replace("_", null);
|
|
14 chars[0]=char.ToUpper(chars[0]);
|
|
15 name = chars.ToString();
|
|
16 }
|
|
17 return name;
|
|
18 };
|
|
19
|
|
20 BeforeGenerateModel = tt =>
|
|
21 {
|
|
22 fieldsPrevBeforeGenerateModel(tt);
|
|
23 Dictionary<string, string> remapper = new Dictionary<string, string>() { { "Exception", "Exceptions" } };
|
|
24
|
|
25 foreach (var t in Tables.Values)
|
|
26 {
|
|
27 t.ClassName = getNetStyleName(t.ClassName);
|
|
28 string className;
|
|
29 if(remapper.TryGetValue(t.ClassName, out className))
|
|
30 t.ClassName = className;
|
|
31 foreach (var c in t.Columns.Values)
|
|
32 c.MemberName = getNetStyleName(c.MemberName);
|
|
33 }
|
|
34 };
|
|
35 }
|
|
36
|
|
37
|
|
38 #> |