Closed PetrPospisil closed 4 years ago
Hi @verdie-g is there a way to pass input-output with a value ? I want to pass value to a sproc and get output from the sproc using the same parameter. I see you have OutputParam class but it is internal, therefor I can not use it.
If possible can you share example code ?
Hello @ornatwork, you should use this overload https://github.com/verdie-g/StoredProcedureEFCore/blob/6171d12503cb1be10b2d842b2dec2cba8cec2304/StoredProcedureEFCore/IStoredProcBuilder.cs#L28
@verdie-g Works as expected, thanks for the great library !
This line must set ParameterDirection.InputOutput rather then ParameterDirection.Output, because it is a in&out routine.
https://github.com/verdie-g/StoredProcedureEFCore/blob/f883a444eb808253efdd6e841826f9bc0d773786/StoredProcedureEFCore/StoredProcBuilder.cs#L44
As a workaround we currently use this piece of code:
// fix missing input output parameter direction var type = builder.GetType().Assembly.GetTypes().Where(t => t.Name == "StoredProcBuilder").First(); var field = type.GetField("_cmd", BindingFlags.NonPublic | BindingFlags.Instance); var sqlCommand = field.GetValue(builder) as SqlCommand; sqlCommand.Parameters[parameterName].Direction = ParameterDirection.InputOutput;
Thx.