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
Abey VarghesePosted Jun 21, 2013, 8:49 AM
Pankaj PandeyPosted Jun 21, 2013, 1:21 AM
Jignesh TrivediPosted Jun 20, 2013, 10:46 PM
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.