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.
Loading

Jignesh TrivediRank #16 · 50.3K reputationPosted Jun 20, 2013, 6:46 PM EDT
hi,
you need import this stored procedure as function.
we can map a returned object of our Stored Procedure. The return type may be a scalar value or a collection of Model Entities or a collection of Complex (Custom) Entity. From this screen we can create a Complex Entity as well.
please refer my article.
http://www.c-sharpcorner.com/UploadFile/ff2f08/call-store-procedure-from-entity-framework/
hope this will help you.
Pankaj PandeyRank #642 · 3.7K reputationPosted Jun 20, 2013, 9:21 PM EDT
Abey Varghese18 reputationPosted Jun 21, 2013, 4:49 AM EDT