Skip to content

Feature: Support the Output Parameters #686

@mikependon

Description

@mikependon

Describe the enhancement

Currently, RepoDB is not supporting the output parameters and/or there is no other way to extract the values.

Let us say, you had created the Stored Procedure below.

CREATE PROCEDURE sp_Multiply
(
	@Input1 INT,
	@Input2 INT,
	@Output INT OUT
)
AS
BEGIN
	SET @Output = (@Input * @Input2);
END

There is no way for us to get the value of the @Output parameter, unless we do it via native ADO.Net.

The current alternative is to return the output value as SCALAR and use the ExecuteScalar method instead. But that requires a small modification on the SP.

var output = connection.ExecuteScalar<decimal>("EXEC sp_Multiply;", new { Input1 = 100, Input2 = 200 });

Proposal

The QueryField object must support the ParamDirection enumeration so the Output value can be utilized. The value of the output parameters must be set back to the Parameter.Value of this object.

var outputQueryField = new QueryField("Output", ParamDirection.Output);
var params = new QueryField[]
{
	new QueryField("Input1", 100),
	new QueryField("Input2", 200),
	outputQueryField
};
var output = connection.ExecuteScalar<decimal>("EXEC sp_Multiply;", params);
/* Get the value from the `outputQueryField.Parameter.Value` */

Or, an object OutputQueryField must be introduced that wraps the proper value of the ParameterDirection of the QueryField object.

var outputQueryField = new OutputQueryField("Output");
var params = new QueryField[]
{
	new QueryField("Input1", 100),
	new QueryField("Input2", 200),
	outputQueryField
};
var output = connection.ExecuteScalar<decimal>("EXEC sp_Multiply;", params);
/* Get the value from the `outputQueryField.Parameter.Value` */

Additional Information

This is up and open for discussion with the .NET community.

Metadata

Metadata

Assignees

Labels

deployedFeature or bug is deployed at the current releaseenhancementNew feature or requestfixedThe bug, issue, incident has been fixed.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions