3
Answers

Return a variable from stored procedure in entity framework

Abey Varghese

Abey Varghese

11y
1.7k
1
I Need to return a value from a stored procedure using entity framework.

My stored procedure is.


ALTER
PROCEDURE [dbo].[okc_usp_CheckWorkOrderId]
@TemplateCheck
VARCHAR(12)
,
@FromDate SMALLDATETIME
,
@IDValue NUMERIC (10,0)
,
@WorkOrderID VARCHAR(20)
,
@ChildDate SMALLDATETIME
--@Flag bit OUTPUT

AS
BEGIN
DECLARE
@Flag bit;
set
@Flag=0;
IF(SUBSTRING(@Templatecheck, DATEPART(MONTH,@FromDate),1 ) = 1 AND
NOT EXISTS(SELECT WORKORDERID FROM azteca.WORKORDER WHERE WORKORDERID = @IDValue)
AND NOT EXISTS (SELECT WORKORDERID FROM azteca.WORKORDER WHERE SOURCEWOID = @WorkOrderID
AND FROMDATE = @ChildDate AND CYCLETYPE = 'A'))

BEGIN
Set @Flag = 1
END
ELSE
BEGIN
Set @Flag=0
END

RETURN @Flag


END


My code is:

using (CWPRTestEntities ctx = new CWPRTestEntities())
{

int Flag= ctx.okc_usp_CheckWorkOrderId(TemplateCheck, FromDate, IDValue, WorkorderID, ChildDate);
}

Error: Best overloaded method match for ....has some invalid arguments.
Answers (3)