Skip to content

Commit

Permalink
Support input/output parameters
Browse files Browse the repository at this point in the history
fixes #1142
fixes #1069
  • Loading branch information
ErikEJ committed Oct 19, 2021
1 parent 3defc36 commit 7c78238
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/GUI/RevEng.Core.Abstractions/Metadata/ModuleParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class ModuleParameter
public int? Scale { get; set; }
public bool Output { get; set; }
public bool Nullable { get; set; }
public string TypeName { get; set; }
public string TypeName { get; set; }
public bool IsReturnValue { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ protected override List<ModuleParameter> GetParameters(SqlConnection connection,
StoreType = "int",
Output = true,
Nullable = false,
IsReturnValue = true,
});

return moduleParameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,22 @@ private void GenerateParameter(ModuleParameter parameter)
_sb.AppendLine($"Size = {parameter.Length},");
}

if (parameter.Output)

if (!parameter.IsReturnValue)
{
_sb.AppendLine("Direction = System.Data.ParameterDirection.Output,");
if (parameter.Output)
{
_sb.AppendLine("Direction = System.Data.ParameterDirection.InputOutput,");
AppendValue(parameter);
}
else
{
AppendValue(parameter);
}
}
else
{
var value = parameter.Nullable ? $"{parameter.Name} ?? Convert.DBNull" : $"{parameter.Name}";
_sb.AppendLine($"Value = {value},");
_sb.AppendLine("Direction = System.Data.ParameterDirection.Output,");
}

_sb.AppendLine($"SqlDbType = System.Data.SqlDbType.{sqlDbType},");
Expand All @@ -349,5 +357,16 @@ private void GenerateParameter(ModuleParameter parameter)

_sb.Append("}");
}

private void AppendValue(ModuleParameter parameter)
{

var value = parameter.Nullable ? $"{parameter.Name} ?? Convert.DBNull" : $"{parameter.Name}";
if (parameter.Output)
{
value = parameter.Nullable ? $"{parameter.Name}?._value ?? Convert.DBNull" : $"{parameter.Name}?._value";
}
_sb.AppendLine($"Value = {value},");
}
}
}
Binary file modified src/GUI/lib/efreveng.exe.zip
Binary file not shown.
Binary file modified src/GUI/lib/efreveng50.exe.zip
Binary file not shown.
Binary file modified src/GUI/lib/efreveng60.exe.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class NorthwindContext
{
private NorthwindContextProcedures _procedures;

public NorthwindContextProcedures Procedures
public virtual NorthwindContextProcedures Procedures
{
get
{
Expand Down Expand Up @@ -220,14 +220,16 @@ public virtual async Task<int> OutputFailAsync(OutputParameter<string> RESPONSES
{
ParameterName = "RESPONSESTATUS",
Size = 20,
Direction = System.Data.ParameterDirection.Output,
Direction = System.Data.ParameterDirection.InputOutput,
Value = RESPONSESTATUS?._value ?? Convert.DBNull,
SqlDbType = System.Data.SqlDbType.VarChar,
};
var parameterRESPONSEMESSSAGE = new SqlParameter
{
ParameterName = "RESPONSEMESSSAGE",
Size = 200,
Direction = System.Data.ParameterDirection.Output,
Direction = System.Data.ParameterDirection.InputOutput,
Value = RESPONSEMESSSAGE?._value ?? Convert.DBNull,
SqlDbType = System.Data.SqlDbType.VarChar,
};
var parameterreturnValue = new SqlParameter
Expand Down Expand Up @@ -363,14 +365,16 @@ public virtual async Task<List<TempObjectsResult>> TempObjectsAsync(int? DetailI
var parameterreturnCode = new SqlParameter
{
ParameterName = "returnCode",
Direction = System.Data.ParameterDirection.Output,
Direction = System.Data.ParameterDirection.InputOutput,
Value = returnCode?._value ?? Convert.DBNull,
SqlDbType = System.Data.SqlDbType.Int,
};
var parameterresult = new SqlParameter
{
ParameterName = "result",
Size = -1,
Direction = System.Data.ParameterDirection.Output,
Direction = System.Data.ParameterDirection.InputOutput,
Value = result?._value ?? Convert.DBNull,
SqlDbType = System.Data.SqlDbType.VarChar,
};
var parameterreturnValue = new SqlParameter
Expand Down Expand Up @@ -426,7 +430,8 @@ public virtual async Task<List<TestResult>> TestAsync(string something, string s
var parametermyOutput = new SqlParameter
{
ParameterName = "myOutput",
Direction = System.Data.ParameterDirection.Output,
Direction = System.Data.ParameterDirection.InputOutput,
Value = myOutput?._value ?? Convert.DBNull,
SqlDbType = System.Data.SqlDbType.Int,
};
var parameterreturnValue = new SqlParameter
Expand Down Expand Up @@ -594,14 +599,16 @@ public virtual async Task<int> TestMethodOutputNoResultAsync(int? testParameter1
{
ParameterName = "testParameter2",
Size = 255,
Direction = System.Data.ParameterDirection.Output,
Direction = System.Data.ParameterDirection.InputOutput,
Value = testParameter2?._value ?? Convert.DBNull,
SqlDbType = System.Data.SqlDbType.VarChar,
};
var parametertestParameter3 = new SqlParameter
{
ParameterName = "testParameter3",
Size = 255,
Direction = System.Data.ParameterDirection.Output,
Direction = System.Data.ParameterDirection.InputOutput,
Value = testParameter3?._value ?? Convert.DBNull,
SqlDbType = System.Data.SqlDbType.VarChar,
};
var parameterreturnValue = new SqlParameter
Expand Down

0 comments on commit 7c78238

Please sign in to comment.