Question

Using Simple.Data, I would like to get the result from an output parameter in a stored procedure. Let's say I have the following SP (disregard the uselessness of it):

CREATE PROCEDURE [dbo].[TestProc]
    @InParam int,
    @OutParam int OUTPUT
AS
BEGIN
    SELECT @OutParam = @InParam * 10
END

When I call it with Simple.Data, I use the following code.

var db = Database.Open();

int outParam;
var result = db.TestProc(42, out outParam);

Console.WriteLine(outParam); // <-- == 0
Console.WriteLine(result.OutputValues["OutParam"]); // <-- == 420

It feels like outParam should contain the value, and not the OutputValues dictionary. So my question is: Is there a nicer way to get the result from OutParam in this particular case?

Was it helpful?

Solution

Unfortunately, out parameters are not supported by the dynamic binding infrastructure used by Simple.Data, as they are not supported in all CLR languages.

I am open to suggestions for better syntax, though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top