tags:

views:

66

answers:

1

Hi

I am new to and getting used to LINQ. I have worked with SPROCS that return result sets. No problems there.

However I am having a problem with OUTPUT params & LINQ.

the stored procedure i simple enough

CREATE PROCEDURE [dbo].[PROCNAME] 
 -- Add the parameters for the 
stored procedure here
   @tcStageOccurrences smallint output

 SELECT @tcStageOccurrences =
           isnull(COUNT(*),0) from 
           Stage where Condition

I am calling this in C# as follows

System.Nullable<Int16> tcStageOccurences = null; 
MyDb.ProcName(ref @tcStageOccurrences);

The value of @tcStageOccurrences is 0 whereas it should be >0

Questions

  1. I have always used SQLparam & ExcuteReader or ExecuteNonQuery without any problems. Since I am trying to do the same thing in LINQ, is there something I am missing out?

I know that i can and probably should be using a scalar function instead.

But in some cases there are multiple OUTPUT parameters that I need to access within C#

Any help or useful tips are most welcome :-)

Regards

+1  A: 

I have got the answer to this after thinking this one over and well it involved somesome experimenting as well

This is what i did 1. Declared an internal / temp variable with type smallint 2. Assigned the count value of the select statement to this variable 3. Assigned the temp variable's value to my output parameter

This works!

Any further comments etc are welcome!!

bornagaindeveloper