Support for output parameters

Jun 4, 2009 at 12:22 AM

Hi there, just like to say great work. 

Will you be adding support for output parameters?

 

Thanks

 

Rohan

Coordinator
Jun 4, 2009 at 12:27 AM

Output parameters are something that I need to look into, but as I don't use OUTPUT parameters it has not made my list yet.

But I will add a TODO for OUTPUT params.

Thank you for the input.

Coordinator
Jul 2, 2009 at 9:42 PM

So I got around to adding support for out parameters for SQL Server, OLEDB, and Sybase.  Here is what the code looks like:

var cmd = new FluentCommand("WithOutParams")
        .SetCommandType(CommandType.StoredProcedure)
        .Add("out1", 9).SetDirection(ParameterDirection.InputOutput)
        .Add("out2", 9).SetDirection(ParameterDirection.InputOutput);
 cmd.AsNonQuery();

 Assert.AreEqual(1, cmd.GetParamValue("out1"));
 Assert.AreEqual(2, cmd.GetParamValue("out2"));

That code is calling a stored procedure call WithOutParams with two parameters.  The first parameter should pass back 1, the second should pass back 2.

The code is in the form of a unit test -- because I copied it straight out of one of my unit tests.