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

Commit 805be36

Browse files
committed
Properly set parameter direction. Escape parameter names to prevent compile issue (e.g. a parameter named "long", or other C# reserved word)
1 parent cd8c8c3 commit 805be36

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/T4/OrmLite.Core.ttinclude

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,21 @@ List<SP> SPsNotSupported(string providerName)
592592
return new List<SP>();
593593
}
594594

595+
string GetParamDirection(SPParamDir direction)
596+
{
597+
switch(direction)
598+
{
599+
case SPParamDir.InAndOutDirection:
600+
return "ParameterDirection.InputOutput";
601+
case SPParamDir.OutDirection:
602+
return "ParameterDirection.Output";
603+
case SPParamDir.InDirection:
604+
default:
605+
return "ParameterDirection.Input";
606+
}
607+
}
608+
609+
595610
List<SP> LoadSPs()
596611
{
597612
InitConnectionString();

src/T4/OrmLite.SP.tt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ namespace <#=SPNamespace#>
3838
}
3939

4040
<#foreach(var sp in sps){#>
41-
public static OrmLiteSPStatement <#=sp.CleanName#>(this IDbConnection db<#foreach(var param in sp.Parameters){#>, <#=param.NullableSysType#> <#=Inflector.MakeInitialLowerCase(param.Name)#> = null<#}#>)
41+
public static OrmLiteSPStatement <#=sp.CleanName#>(this IDbConnection db<#foreach(var param in sp.Parameters){#>, <#=param.NullableSysType#> @<#=Inflector.MakeInitialLowerCase(param.Name)#> = null<#}#>)
4242
{
4343
var dbCmd = (DbCommand)OrmLiteConfig.ExecFilter.CreateCommand(db).ToDbCommand();
4444
dbCmd.CommandText = "<#=sp.Name#>";
4545
dbCmd.CommandType = CommandType.StoredProcedure;
4646
<#if (sp.Parameters.Count > 0) { foreach(var param in sp.Parameters){#>
47-
dbCmd.Parameters.Add(CreateNewParameter(dbCmd,"<#=param.Name#>",<#=Inflector.MakeInitialLowerCase(param.Name)#>,ParameterDirection.Input,<#=param.DbType#>));
47+
dbCmd.Parameters.Add(CreateNewParameter(dbCmd,"<#=param.Name#>",@<#=Inflector.MakeInitialLowerCase(param.Name)#>,<#=GetParamDirection(param.Direction)#>,<#=param.DbType#>));
4848
<#}#> <#}#>
4949
return new OrmLiteSPStatement(db, dbCmd);
5050
}

0 commit comments

Comments
 (0)