Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 347ded8

Browse files
committed
Alias SP output classes on columns which start with digit and underscore property. Fix Poco to output properties starting with digits correctly.
1 parent 5f6d758 commit 347ded8

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/T4/OrmLite.Core.ttinclude

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,14 @@ static Func<string, string> CleanUp = (str) =>
276276
{
277277
str = rxCleanUp.Replace(str, "_");
278278

279-
if (char.IsDigit(str[0]) || cs_keywords.Contains(str))
279+
if (char.IsDigit(str[0]))
280+
{
281+
str = "_" + str;
282+
}
283+
else if (cs_keywords.Contains(str))
284+
{
280285
str = "@" + str;
286+
}
281287

282288
return str;
283289
};

src/T4/OrmLite.SP.tt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
var SPNamespace = "StoredProcedures";
66
ClassPrefix = "";
77
ClassSuffix = "";
8-
8+
99
// Read schema
1010
var sps = LoadSPs();
1111

@@ -22,6 +22,7 @@ using System.Data.Common;
2222
using System.Data;
2323
using System.Collections.Generic;
2424
using ServiceStack.OrmLite;
25+
using ServiceStack.DataAnnotations;
2526

2627
namespace <#=SPNamespace#>
2728
{
@@ -57,11 +58,14 @@ namespace <#=SPNamespace#>
5758
if (!sp.SPOutputColumns.Any()) continue; #>
5859
public class <#=sp.CleanName#>_Result
5960
{
60-
<#foreach(var prop in sp.SPOutputColumns){#>
61+
<# foreach(var prop in sp.SPOutputColumns){ if (char.IsDigit(prop.Name[0])) { #>
62+
[Alias("<#=prop.Name#>")]
63+
public <#=prop.DotNetType#> _<#=prop.Name#> { get; set; }
64+
<#} else {#>
6165
public <#=prop.DotNetType#> <#=prop.Name#> { get; set; }
62-
<#}#>
66+
<#}}#>
6367
}
6468
<#}#>
6569

6670
}
67-
<#}#>
71+
<#}#>

0 commit comments

Comments
 (0)