When you work with stored procedures, sometime you need to get values via output parameters.

So for a simple stored procedure that looks like this:

ALTER PROCEDURE dbo.[WithOutParams]( @out1 int output,
	@out2 int output  )
AS
BEGIN
	SET @out1 = 1
	SET @out2 = 2
END


Here is the code you would write:
var cmd = new FluentCommand<string>("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"));

Last edited Jul 2, 2009 at 8:51 PM by cwbrandsma, version 1

Comments

No comments yet.